Reputation: 1011
I have a query as mentioned below.
var projstat = ['A' , 'B'];
Post.native(function(err, collection) {
if (err)
console.log(err);
collection.find({
'status': {
"$in": projstat
}
}, {multi: true}, function(err, result) {
console.log(result);
if (req.isSocket) {
return res.json(result);
}
});
});
Please correct me if i am wrong as it doesnot return any results. Please help.
Upvotes: 3
Views: 1748
Reputation: 24948
You're not using the native find
correctly; rather than using a callback as an argument (like Waterline does), you chain the call to toArray
and use the callback as its argument:
collection.find({
'status': {
"$in": projstat
}
}).toArray(function(err, results) {...});
Docs for the native Mongo driver are here.
However, the more important point in this case is that you don't need native
at all. You can use the regular Waterline find
, which automatically does an in
query when an attribute is set to an array:
Post.find({status: projstat}).exec(function(err, results) {...});
Upvotes: 3