Max
Max

Reputation: 2783

How can i do an "or" query in a Model.find on Sails?

i have to make a query that accept two entries from a field in Sails. Since Sails use waterline for ORM i've also tagged it on this question.

    Conversions.find({status : 0} || {status : 2}).exec(function(err, convs){
      // do something 
    });

This don't work, there is a solution using Sails/Waterline or i should go for a custom query?

Many thanks

Upvotes: 1

Views: 139

Answers (1)

myusuf
myusuf

Reputation: 12240

You could try this:

Conversions.find().where({
  or: [
    {status: 0},
    {status: 1}
  ]
  }).exec(function(err, convs){
      // do something 
});

Using $or will work, but for a native query, and not for waterline AFAIK.

Hope this helps.

Upvotes: 4

Related Questions