Hey guys,
I’m having a little problem in one of my template helpers. Just for example, I try to get all stats that are smaller than the current month:
pastStats: function () {
var month = moment().month() + 1; //to get the current month
var year = moment().year(); //to get the current year
//show me all stats that are smaller than current month and year
return Stats.find({
userId: Meteor.userId(),
$and: [{month: {$ne: month}}, {year: {$ne: year}}]
}, {sort: {createdAt: 1}, limit: 6});
}
This isn’t working. If I remove “{year: {$ne: year}}”, it works. I’m just wondering, because it seems like Mongo handles it like an OR condition, f.e.: “Find all stats that are not having the current month OR the current year” - but I need “Find all stats that are not having the current month AND the current year”. So what is wrong in my query?