title: mongo query from loopback issue
body: <p>I am trying to query in mongo db from loopback model. But i am not getting any result from monogdb</p>
  
  <p>This is how my document looks like in mongodb</p>
  
  <pre><code>{"_id":"5b9f8bc51fbd7f248cabe742",
  "agentType":"Online-Shopping",
  "projectId":"modroid-server",
  "labels":["category","price"],
  "phrases":["Look for _^ct_ in _^p_ ",
  "I need _^ct_ in _^p_",
  "can you search for _^ct_ in _^p_"]
  }
  </code></pre>
  
  <p>here is my datasource file</p>
  
  <pre><code>{
  "db": {
  "name": "db",
  "connector": "memory"
  },
  "modroid-server": {
  "host": "localhost",
  "port": 27017,
  "url": "",
  "database": "modroid-server",
  "password": "",
  "name": "modroid-server",
  "user": "",
  "connector": "mongodb"
    }
  }
  </code></pre>
  
  <p>and here  is model-config file</p>
  
  <pre><code>{
  "_meta": {
  "sources": [
    "loopback/common/models",
    "loopback/server/models",
    "../common/models",
    "./models"
  ],
  "mixins": [
    "loopback/common/mixins",
    "loopback/server/mixins",
    "../common/mixins",
    "./mixins"
  ]
  },
  "User": {
  "dataSource": "db"
  },
  "AccessToken": {
  "dataSource": "db",
  "public": false
  },
  "ACL": {
  "dataSource": "db",
  "public": false
  },
  "RoleMapping": {
  "dataSource": "db",
  "public": false,
  "options": {
    "strictObjectIDCoercion": true
  }
  },
   "Role": {
  "dataSource": "db",
  "public": false
   },
  "agent": {
  "dataSource": "modroid-server",  // here is my mongodb
  "public": true
   }
  }
  </code></pre>
  
  <p>and here is my code to query in mongodb</p>
  
  <pre><code>module.exports = function (Agent) {
  Agent.getDataSource().connector.connect(function (err, db) {
          var collection = db.collection("text-responses");
          collection.find({ "where": { "labels":  ["category", "price"]  } }, function (err, res) { // define whichever query you need
              console.log("collection find res:"+res);
              console.log("collection find err:"+err);
  
              if(err) {
              cb(err);
              return;
            }
            res.toArray(function (err, realRes) { // this part is crucial
            // otherwise if you try to print res you will get a dump of the db object
              if(err) {
                cb(err);
                return;
              }
              console.log("documnet result:"+realRes);
              console.log("document err:"+err);
            })
        })
      }
      );
  }
  </code></pre>
  
  <p>and when i hit that rest api. I get this output</p>
  
  <pre><code>collection find res:[object Object]
  collection find err:null
  documnet result:
  document err:null
  </code></pre>
  
  <p>please help me where i am doing thing wrong. I am stuck in that from couples of days. </p>
  
  <p><strong>Edited</strong></p>
  
  <p>when i just print <strong>res</strong> it gives me huge data which starts as </p>
  
  <pre><code>Cursor {
  pool: null,
  server: null,
  disconnectHandler:
  Store {
   s: { storedOps: [], storeOptions: [Object], topology: [Object] },
   length: [Getter] },
  bson: BSON {},
  ns: 'modroid-server.text-responses',
  cmd:
  { find: 'modroid-server.text-responses',
   limit: 0,
   skip: 0,
   query: { where: [Object] },
   slaveOk: true,
   readPreference: ReadPreference { mode: 'primary', tags: undefined } },
  </code></pre>