mongodb having multiple conditions for $ne

mongodb

Solution

You can use the $nin operator:

db.rest.find({ borough : {$nin : ["Brooklyn", "Queens", "Staten Island"]}});

Ref: https://docs.mongodb.com/manual/reference/operator/query/nin/

Problem

Im trying to do a query where I exclude certain borough names such as Brooklyn, Queens, and Staten Island, I was able to exclude just one but can not figure out how to exclude more then just one excluding just one: db.rest.find({ borough : {$ne : "Brookyln"}}); this worked just to exclude one and so I looked around to see how I can do multiple and tried db.rest.find({ borough : {$ne : ["Brooklyn", "Queens", "Staten Island"]}}); which did not work, how can I accomplish this?

Original source