LearnBoost/mongoose — Issue #674: $nor operator
Author: krogers
Created: 2012-01-06 22:07:25+00:00
State: open

I have a collection which stores some arrays of user Id's - I want to check if a particular Id is included in one or more of the arrays to get the resulting collection entries. Here is an example for checking it's existence in two different groups with Mongoose, which works fine :

var query = model.find({$or: [{admins: userId}, {powerUsers: userId}]});

However, how can I accomplish the inverse? Meaning, give me all of the results where a particular Id is not in the arrays I'm matching against? In the mongo shell, I can do the following with the $nor operator, and it works:

db.userGroups.find({$nor : [{admins: 1234}, {powerUsers: 1234}]});

However, $nor does not work in the first query through Mongoose, and after digging into the Mongoose API, I don't see it specified.