【发布时间】:2018-07-06 14:06:45
【问题描述】:
我们有这个 MongoDB Mongoose 查询:
sampleSchema.find({
$where: "expired <= " + (new Date())
})
.limit(9)
.sort({
postedDate: -1
})
.then((docs) => {
console.log('found docs ', docs);
})
.catch((err) => {
console.log('error ', err);
})
此查询总是转到catch 块并且抛出的错误是:
{
"name": "MongoError",
"message": "Failed to call method",
"ok": 0,
"errmsg": "Failed to call method",
"code": 1,
"codeName": "InternalError"
}
这个查询有什么问题?
【问题讨论】:
-
试试
{expire: {$lte : (new Date())}。 -
@Titus 它按预期工作,非常感谢!
-
太棒了。我很高兴能帮上忙。
-
在错误消息中提及出现了什么问题不是很好吗? “InternalError”几乎没有帮助
-
@asgs 错误消息来自 MongoDB。我们无法控制它
标签: javascript json node.js mongodb mongoose