我的node.js应用程序已声明此函数:
//deletes a user and its related files.
function deleteUser(userToDelete)
{
if (userToDelete == null || userToDelete == {})
{
return { success: false, message: 'error deleting user 1.'};
}
{
return { success: false, message: 'error deleting user 2.'};
}
// delete the entry from the database
User.findOneAndRemove({ email: userToDelete}, function(err, filesList) {
if (err)
{
return { success: false, message: 'error deleting user.3'};
}
});
//delete related files
UserFile.remove({owner:userToDelete}, function(err,filesList){
if (err)
{
return { success: false, message: 'user deleted. Error deleting related files.'};
}
return { success: true, message: 'user deleted.'};
});
};
我注意到这部分不应该出现在那里:
{
return { success: false, message: 'error deleting user 2.'};
}
所以我删除了它,保存了文件,关闭了节点,然后再次运行它。但是,调用该函数的api端点会一直返回{success:false,message:'错误删除用户2。'}。我已经确保我的代码库的任何其他位置都没有这个JSON字符串,没有可以运行的代码产生这个结果,但它仍然被执行。怎么了?为什么旧的删除代码被执行,是否有任何类型的缓存,我不知道存活重置节点?