admin管理员组文章数量:1328037
I'm developing an app with mongoose to access MongoDB.
And what I'm trying to achieve is to make a query and discar some documents by id.
User.find({})
.where('price').lt(upperLimit)
....
.exec(function(err, users) {
//
});
The point is I want to discard some users that I know before doing the query. Any ideas?. I don't want to post-process users collections and filter.
Thanks!
I'm developing an app with mongoose to access MongoDB.
And what I'm trying to achieve is to make a query and discar some documents by id.
User.find({})
.where('price').lt(upperLimit)
....
.exec(function(err, users) {
//
});
The point is I want to discard some users that I know before doing the query. Any ideas?. I don't want to post-process users collections and filter.
Thanks!
Share Improve this question asked Mar 13, 2013 at 13:11 Javier ManzanoJavier Manzano 4,83116 gold badges59 silver badges90 bronze badges2 Answers
Reset to default 3You can use the $nin
operator to exclude an array of _id
values:
User.find({})
.where('price').lt(upperLimit)
.nin('_id', idsToExclude)
....
.exec(function(err, users) {
//
});
You could use the $ne operator:
User.find({"_id":{"$ne":<IdToExclude>}}). …
本文标签: javascriptFiltering query results with mongoose on nodejsStack Overflow
版权声明:本文标题:javascript - Filtering query results with mongoose on node.js - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742237215a2438296.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论