如何在环回中执行原始 mongodb 查询

Pho*_*Dev 3 mongodb node.js loopbackjs

如何在环回远程方法中执行原始 mongo db 查询?我试过:

    Members.getDataSource().connector.connect(function (err, db) {
          var collection = db.collection('Members');
          var res = collection.find();
          console.log(res);
   });
Run Code Online (Sandbox Code Playgroud)

在这里, res 为我提供了一个对象内的大量数据,但我无法从该对象中找到任何结果文档。任何帮助将不胜感激!谢谢 !

Ebr*_*ani 5

它也是异步的。

    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);
            });
          });          
   });
Run Code Online (Sandbox Code Playgroud)