Node.js 如何在环回中执行原始mongodb查询
如何在环回远程方法中执行原始mongo db查询? 我试着说:Node.js 如何在环回中执行原始mongodb查询,node.js,mongodb,loopbackjs,Node.js,Mongodb,Loopbackjs,如何在环回远程方法中执行原始mongo db查询? 我试着说: Members.getDataSource().connector.connect(function (err, db) { var collection = db.collection('Members'); var res = collection.find(); console.log(res); }); 在这里,res在一个对象中给了我大量的数据,但
Members.getDataSource().connector.connect(function (err, db) {
var collection = db.collection('Members');
var res = collection.find();
console.log(res);
});
在这里,res在一个对象中给了我大量的数据,但是我找不到来自该对象的任何结果文档。任何帮助都将不胜感激!谢谢
! 它也是异步的
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);
});
});
});
我试过这样做,但是consoled对象包含大量的数据,在这些数据中我找不到任何结果行。是否有任何特定的键可以从保存结果的res对象调用?我们不需要在这里关闭连接吗?它非常有用。