【问题标题】:Failed to call method调用方法失败
【发布时间】: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


【解决方案1】:

分享给未来的读者:

这成功了:

{expire: {$lte : (new Date())}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2010-10-18
    • 1970-01-01
    相关资源
    最近更新 更多