0

I'm using the Waterline ORM (MongoDB adapter) with SailsJS and trying to return all documents that don't match the specified query along the lines of this:

    User.find({
        id: { $nin: [array] }
    }).done(...)

I understand that when passing in an array it will automatically query with the $in operator, but how can I query with the $nin operator?

Travis Webb
  • 13,507
  • 6
  • 51
  • 101
btown
  • 33
  • 4
  • 1
    it should be absolutely the same. (Or at least the syntax in mongo is the same) – Salvador Dali Nov 19 '13 at 20:03
  • It doesn't seem to be the same. I've tried using the same syntax as in mongodb. For example, to use the $in operator in Waterline you just simply pass in the array and don't need to specify the $in operator. – btown Nov 20 '13 at 01:43
  • 1
    Another reason not to use some weird adapters/frameworks/tools for things that can be easily solved without them. Especially if they are not properly documented. – Salvador Dali Nov 20 '13 at 01:48

1 Answers1

1

Currently works in the master branch of sails-mongo.

User.find({
    id: { '!': [array] }
}).exec(/* ... */)

In Waterline IN queries are done with an array of values. The query language works the same in all the adapters.

You can read more on the Waterline-Docs

particlebanana
  • 2,426
  • 18
  • 22