node.js - 带有限制选项的僧侣排序

标签 node.js mongodb

我正在尝试以下列方式在 monk api 中使用限制和排序:

db.user.find({ changesId : '1234' }, { limit :4 , sort : { name : 1 } }, function (err,res) {

});

在这种情况下,排序似乎不起作用。我做错了什么?

最佳答案

您的代码不正确 - } 丢失。正确的是:

db.user.find({ changesId : '1234' },
    { limit : 4, sort : { name : 1 } }, // <-  here
    function (err,res) { });

关于node.js - 带有限制选项的僧侣排序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19954916/

相关文章:

node.js - 从s3下载文件而不将其写入nodejs中的文件系统

node.js - Mongoose 栖息在哪里

node.js - res.Send 会导致 404 错误吗?

javascript - Node.JS 作业/后台进程和高可用性

mongodb - 使用 mgo 更新插入到分片 MongoDB 错误 "full shard key must be in update object for collection:..."

node.js - RabbitMQ "access to vhost ' OWN' 被拒绝”

python - 插入 Mongo 时如何处理 json 中的长整型?

javascript - meteor.js - 设置 Controller 来访问集合

javascript - 通过 POST 请求更新 Mongoose 模式的属性

java - MongoDB 和 Spring