[英]How can I add another condition to my search query in mongoose.js?
User.find({problem_no:1})
.count()
.exec(function (err, count) {
res.send({user_problem_no_1: count})
})
Above is my query and it counts all the entries in my collection that says problem_no
has a value 1
. 上面是我的查询,它对我的集合中所有
problem_no
的值1
的条目进行计数。 I want to include here also verification of a date, so that I want to count only entries where problem_no == 1
and that created_at
is greater or equal someDate
. 我想在这里还包括一个日期验证,以便只计算在
problem_no == 1
且created_at
大于或等于someDate
。 How should I modify this query to perform it? 我应该如何修改此查询以执行它?
with and you can do this 与,你可以做到这一点
User.find()
.and([
{problem_no: 1},
{'created_at': date}} // i think in millieseconds
])
.sort({created_at: -1})
.exec(function (err, user) {
// do stuff
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.