title: saving video/images to MongoDB in NodeJS server by using GridFS
body: <p>I am looking for a sample example for storing videos/images in <code>MongoDB</code> using <code>GridFS</code>. I came across <a href="https://mongodb.github.io/node-mongodb-native/api-articles/nodekoarticle2.html" rel="nofollow">this official site</a> and followed the below code snippet</p>
  
  <pre><code>var MongoClient = require('mongodb').MongoClient,
  Grid = mongo.Grid;
  // Connect to the db
  MongoClient.connect("mongodb://localhost:27017/exampleDb", function(err, db) {
    if(err) return console.dir(err);
    var grid = new Grid(db, 'fs');
    var buffer = new Buffer("Hello world");
    grid.put(buffer, {metadata:{category:'text'}, content_type: 'text'}, function(err, fileInfo) {
      if(!err) {
        console.log("Finished writing file to Mongo");
      }
    });
  });
  </code></pre>
  
  <p>When I run the code I am getting bellow error</p>
  
  <pre><code>Grid = mongo.Grid;
         ^
  ReferenceError: mongo is not defined
  at Object.&lt;anonymous&gt; (D:\Rahul\Nodejs\Fileupload\fileupload\Samples\grid-fs
  \mongo.js:3:8)
  at Module._compile (module.js:434:26)
  at Object.Module._extensions..js (module.js:452:10)
  at Module.load (module.js:355:32)
  at Function.Module._load (module.js:310:12)
  at Function.Module.runMain (module.js:475:10)
  at startup (node.js:117:18)
  at node.js:951:3
  </code></pre>
  
  <p>please share any link for How to store files in MongoDB using GridFS in Nodejs.</p>
  
  <p><strong>EDIT 1</strong></p>
  
  <p>I tried a lot to get it work and finally I come to know the interface <code>Grid</code> is removed from <code>Mongodb 2.1</code> so It won't work but there is no documentation for the replacement of Grid. Now I don't have clear idea about which one to use i.e <code>GridStore</code>, <code>GridFSBucket</code>, etc</p>
  
  <p>Is this documentation misleading? </p>