javascript - Waterline query of arrays separated "OR" -
i'm trying sails backend rest call retrieves me items either "country" column or "subcountry" column matches array have. i've tried:
{ skip: 0, where: { or: [ {country: ['argentina', 'brasil']}, {subcountry: ['argentina', 'brasil']} ] } }
but return 0 records.
looks problem have implicit "in" on each "or" term. i'm querying mongo database.
it's not "pretty" idea, since $in
$or
shorter notation form still should able long notation form same:
{ "where": { "or": [ { "country": "argentina" }, { "country": "brasil" }, { "subcountry": "argentina" }, { "subcountry": "brasil" } ] } }
alternately can accept using "native" query form instead:
model.native(function(err,collection) { collection.find({ "$or": [ { "country": { "$in": [ "argentina", "brasil" ] } }, { "subcountry": { "$in": [ "argentina", "brasil" ] } }, ] }).toarray(function(err,docs) { }); });
since there nothing wrong query form itself, how being serialized mongodb waterline.
Comments
Post a Comment