Mongoose 和 Express:查找总是返回 null
我总是在代码中的任何地方的任何 find() 中得到返回 null 的结果。上周这一切都有效。我的数据库运行正常。这是一个示例:
var getParcourList = function(userId, callback){
GeneralReference.findOne({ id: userId}, function(err, result){
var callB;
if(err || result === null){
console.log("error in save: " + err + " - User returned for " + userId + " : " + result);
callB = "No Document found: " + err;
}else{
console.log(userId + " : " + result);
callB = result.parcours;
}
callback(callB);
});
}
I always get a null returned for result in any find(), anywhere in my code. It all used to work last week. My database is running properly. Here is a sample:
var getParcourList = function(userId, callback){
GeneralReference.findOne({ id: userId}, function(err, result){
var callB;
if(err || result === null){
console.log("error in save: " + err + " - User returned for " + userId + " : " + result);
callB = "No Document found: " + err;
}else{
console.log(userId + " : " + result);
callB = result.parcours;
}
callback(callB);
});
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论