Reputation: 911
I want to get all stream data with thread value but not including null
. On my mongodb console it works with $ne
but on my query sails model it always returns undefined
?
Example query:
Stream.findOne({thread: {$ne: null } }, function(err, st){
if(err) return err;
console.log("st", st);
});
How can I resolve this?
Upvotes: 2
Views: 442
Reputation: 103365
Use the .native()
method:
Stream.native(function(err, collection) {
if (err) return res.serverError(err);
collection.find({
"thread": { "$ne": null }
}).toArray(function(err, st) {
if (err) return res.serverError(err);
console.log("st", st);
return res.ok(st);
});
});
Or the .where()
method:
var myQuery = Stream.find();
myQuery.where({'thread':{ '$ne': null}});
myQuery.exec(function callBack(err, results){
console.log(results)
});
Upvotes: 1