我在猫鼬上运行了一个查找:
var mongoose = require("mongoose");
let User = require("@myRepo/myapp").user;
function getUser(){
mongoose.set("debug", true);
User.find({ _id: currentUserId })
.limit(1)
.exec(function(err, user) {
if (err) {
console.log("err: " + err);
throw err;
}
console.log("user: ", user);
});
}
查找运行成功但在 exec 运行之前,每次控制台日志中都会出现猫鼬错误。函数(err, user) 上没有错误被抛出!!!
这是一个猫鼬错误:
myapp | [2017-08-11T15:30:38.505Z] ERROR: sys/289 on 58e82c8426b7: Mongoose: user.find({ _id: 10646 }, { limit: 1, fields: {} }) (type=app)
没有关于这个猫鼬错误的详细信息。我该如何分析这个错误?
mongoose.set("调试", true); - 没有效果
消息:
myapp | [2017-08-11T15:30:38.505Z] ERROR: sys/289 on 58e82c8426b7: Mongoose: user.find({ _id: 10646 }, { limit: 1, fields: {} }) (type=app)
是 mongoose 调试模式下的典型 mongoose 日志消息。消息中的文本“错误:”在我看来是一个错误。
如果在代码中全部注释或删除
mongoose.set("debug", true);
并将配置日志级别设置为“信息”或更低
logging: {
level: "info"
},
所有日志消息(在我们的例子中所有带有“ERROR:”的消息)消失。
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句