var MongoClient = require('mongodb').MongoClient,
    GridStore = require('mongodb').GridStore,
    Grid = require('mongodb').Grid;
MongoClient.connect("mongodb://localhost/", function(err, db) {
  var grid = new Grid(db, 'fs');
  var data = new Buffer('Witaj, świecie');
  console.log("\nOryginalne dane: ");
  console.log(data.toString());
  grid.put(data, {_id: "test.file"}, function(err, results) {
    console.log("\nWyniki metody put: ");
    console.log(results);
    grid.get("test.file", function(err, data) {
      console.log("\nPrzed użyciem metody delete: ");
      console.log(data.toString());
      grid.delete("test.file", function(err, results) {
        console.log("\nWyniki metody delete: ");
        console.log(results);
        db.close();
      });
    });
  });
});