title: Access remote mongodb from node
body: <p>I want to access the remote mongodb data through node. Have written following in my app.js :</p>
  
  <pre><code>var mongo = require('mongodb');
  var MongoClient = require('mongodb').MongoClient;
  var db = MongoClient.connect("mongodb://remote_url:27017/databasetest");
  //db name is : databasetest
  
  app.use(function(req,res,next){
    req.db = db;
    next();
  });
  </code></pre>
  
  <p>Following is the api written to access a collection from the db:</p>
  
  <pre><code>router.get('/get', function(req, res, next) {
   var db = req.db;
   var collection = db.get('test');
   collection.find({},function(e,docs){
      res.json(docs);
   });
  });
  </code></pre>
  
  <p>I am getting the following error while accessing the API :</p>
  
  <p><strong>db.get is not a function</strong></p>
  
  <p>Could someone help me for the same</p>