var MongoClient = require('mongodb').MongoClient;
MongoClient.connect("mongodb://localhost/", function(err, db) {
  var myDB = db.db("astro");
  myDB.collection("nebulae", function(err, nebulae){
    nebulae.findOne({type: "supernova"}, function(err, item){
      console.log("Przed zapisaniem: ");
      console.log(item);
      item.info = "Nowe informacje";
      nebulae.save(item, {w:1}, function(err, results){
        nebulae.findOne({_id:item._id}, function(err, savedItem){
          console.log("Po zapisaniu: ");
          console.log(savedItem);
          db.close();
        });
      });
    });
  });
});