How can I execute a raw mongo db query in loopback remote method? I tried like:
Members.getDataSource().connector.connect(function (err, db) {
var collection = db.collection('Members');
var res = collection.find();
console.log(res);
});
Here, res gives me a huge amount of data inside an object, but I cant find any result documents from that object. Any help will be appreciated! Thanks !
It is async too.
Members.getDataSource().connector.connect(function (err, db) {
var collection = db.collection('member_col'); //name of db collection
collection.find(function(err, res){
res.toArray(function(err, realRes){
console.log(realRes);
});
});
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With