【发布时间】:2017-12-20 08:31:25
【问题描述】:
我需要根据一些参数查询我的 Mongo DB。但是,要获取参数,无论如何我首先需要使用 find() ,然后进行一些计算。
这显然是没有效率的。
让我详细说明:
这是我要查询的收藏:
{
"title": "1",
"description": "1",
"aCounter": 100,
"bCounter": 20,
"__v": 0
}
我想查找 aCounter - bCounter 大于 50 的帖子。
我已经准备好模型和一切,但不知道在 find() 参数中放入什么。
postModel.find({
//I don't know what to put here
})
.exec(function(err, posts) {
if(posts){
//return the data
}
});
任何输入都会有所帮助。
谢谢
【问题讨论】:
标签: mongodb mongoose mongodb-query aggregation-framework