node.js - 按日期排序 Mongoose 抛出错误记录超过 9

标签 node.js mongodb mongoose

我正在获取


Error: too much data for sort() with no index

按日期升序排序时。仅当记录数超过 9 时,我才会出现此异常。有人可以告诉我我做错了什么吗?或者有什么解决办法吗?

我的排序语法是:

image.find({reviewed:true },null,{sort:{"submittedDate":-1}}, function (err, images){});

最佳答案

根据此处的文档:http://www.mongodb.org/display/DOCS/Indexes#Indexes-Using {{sort%28%29}}没有索引

You may use sort() to return data in order without an index if the data set to be returned is small (less than 32 megabytes in version 2.0, or less than four megabytes in version 1.8 and earlier). For these cases it is best to use limit() and sort() together.

这 9 个文档实际上可能大于 32 兆字节吗?或者,像以前的版本一样,超过 4 兆字节?

关于node.js - 按日期排序 Mongoose 抛出错误记录超过 9,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13341218/

相关文章:

mongodb - 聚合和展开数组,但保留顶级 key

javascript - 像 Trello 这样的项目,在 Mongoose 中创建一个合适的数据库

node.js - 从 "long polling"开始

javascript - 运行 mocha 单元测试时,如何避免我的 Q Promise catch block 在 NodeJS 回调式 API 中被调用两次?

javascript - 有时机器人不会添加角色并设置昵称

node.js - 如何在 react 中显示base64图像?

mongodb - golang + mongodb : sanitize input

javascript - Mongoose 中字段的每个不同值的行数

node.js - 将数组推送到 mongodb 的数组字段中

node.js - forEach 中的 Puppeteer 测试