Reputation: 2803
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
. 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
. How should I modify this query to perform it?
Upvotes: 0
Views: 80
Reputation: 541
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
}
Upvotes: 0