title: MongoDb how to get all the objects in the document from client side
body: <p>I am trying to save the whole MongoDB object in the schema but I can only get the undefined value only</p>
  
  <pre><code>var MongoClient = require('mongodb').MongoClient;
      var url = "mongodb://localhost:27017/";
  
      MongoClient.connect(url,function(err,db){
          if(err){
              console.log("no connect")
          }
         var dbo = db.db("mydb");
         var query = {name:"Company Inc"};
         dbo.collection("customers").find(query).toArray(function(err, result) {
          if (err) throw err;
          console.log(result);
          db.close();
        });
      });
  </code></pre>
  
  <p>Actually it is throwing error</p>
  
  <pre><code> W NETWORK [thread1] Failed to connect to 127.0.0.1:27017, in(checking socket for error after poll), reason: errno:111 Connection refused
  </code></pre>
  
  <p>I am connecting to the DB and I want to get the all the data from the MongoDB document</p>
  
  <p>Thanks in advance!</p>