mongoDB 查询查找限制为 100?

mongoDB query find is limited at 100?

我的应用程序不再可用!

我发现这个没有成功:

我的应用程序在几个月内很稳定,我没有更新我的脚本。

几天来,一些查询不再有效!

这是你的:我的原始脚本,但它不再起作用了:

console.log("GO_1"); // display ok

models.myCollectionOne.find().sort({ created: 'desc' }).then(function (err,data) {
  console.log("GO_2"); // here I've got nothing on console
  console.log(err); // here I've got nothing on console
  console.log(data);  // here I've got nothing on console
}
// here nothing happens ?

我测试了这个:

models.myCollectionOne.find().limit(101).then(function (data) {
  console.log("GO_2"); // OK
  console.log(data); // ok
}

所以,我的问题是:

1) 为什么我的原始脚本不再起作用?

2) 您知道是否有更新影响我的脚本吗?

3) 为什么 limit(101) 有效而不是 limit(102 或更多)?

感谢您的帮助

我认为问题出在 sort 上。我认为 'desc' 不是有效值,您可以尝试将其替换为 -1:{ created: -1 }

(我刚刚在这里使用 'desc' 进行了测试并得到了 "$err" : "Can't canonicalize query: BadValue bad sort specification"

也许你 Mongodb 更新了但它停止工作了?

所以,我发现了我的问题,我只需要更新我所有的节点模块包,主要是 mongoose,

所以现在,一切都很好。

顺便说一句,我已经看到我更新了我的主要 package.json 但没有更新模块 npm 本身 ;-)

@Hampus @andrek 谢谢大家的帮助