MongoDB在不应该返回结果时返回结果
我在一个集合中搜索数组,Mongodb(Mongoose)返回一个空数组,尽管我知道它不应该找到我提交的URL路径MongoDB在不应该返回结果时返回结果,mongodb,express,mongoose,Mongodb,Express,Mongoose,我在一个集合中搜索数组,Mongodb(Mongoose)返回一个空数组,尽管我知道它不应该找到我提交的URL路径 router.use(function(req, res, next) { var path = req.url; db.find({arrayOfPaths:path}) .then(function(db){ console.log(db); //db returns empty array why? res.status(200).render('re
router.use(function(req, res, next) {
var path = req.url;
db.find({arrayOfPaths:path})
.then(function(db){
console.log(db);
//db returns empty array why?
res.status(200).render('results', {db});
})
.catch()
})
因为猫鼬就是这么做的。
.find()
的结果始终是一个数组。空不空。因此,无结果是一个没有条目的数组。非常感谢。澄清了这一点。:)