title: mongodb throwing error while saving data (topology destroyed)
body: <p>I am trying to write data to MongoDB using Node.js
  While writing the data, I am getting the following error in the last line.
  Execution logs are:</p>
  
  <pre><code>{ _id: 56e90c1292e69900190954f5, 
  nfs: [ 'ebdp1', 'ebdp2', 'ebdp3', 'ebdp4' ],
  snapShotTime: '2016-03-16 07:32:34' }
  { [MongoError: topology was destroyed] name: 'MongoError', message: 'topology was destroyed' }
  </code></pre>
  
  <p>My code structure is according to the framework, where Collection's schema is in <code>appTableProdSchema.js</code> file, and the Object data in <code>appTableProdData.js</code> file. 
  The Main is newMain.js</p>
  
  <p>Code is as follows:
  newMain.js</p>
  
  <pre><code>var mongoose = require('mongoose');
  var moment = require('moment');
  var nfs_check="";
  var promises = [];
  
  var nodes = ["ebdp1","ebdp2", "ebdp3", "ebdp4"];
  
  mongoose.connect('mongodb://localhost:27017/test');
  var db = mongoose.connection;
  var storageData = require('./appTableProdData.js');
  var storageDataSchema = require('./appTableProdSchema.js');
  var obj = {};
  obj.snapShotTime = moment().utc().format("YYYY-MM-DD HH:mm:ss");
  obj.nfs = nodes;
  db.once('open', function() {
      var mongoData = new storageData();
      mongoData.fill(obj);
      var promise = new storageDataSchema(mongoData.getInformation());
      console.log(promise.toString());
      promise.save(function (err, promise) {
              if (err) return console.error(err);
              promise.speak();
          }); 
  });
  mongoose.disconnect();
  </code></pre>
  
  <p>appTableProdSchema.js</p>
  
  <pre><code>var mongoose = require('mongoose');
  
  module.exports = mongoose.model('AppTableProd', {
      snapShotTime : String,
      nfs: Array    
  });
  </code></pre>
  
  <p>appTableProdData.js</p>
  
  <pre><code>var storageData = function() {
      this.data =  {
              snapShotTime: null,
              nfs: null    
      };
      this.fill = function(resp) {
          this.data.snapShotTime = resp.snapShotTime;
          this.data.nfs = resp.nfs;
      };
      this.getInformation = function() {
          return this.data;
      };
  };
  module.exports = storageData; 
  </code></pre>
  
  <p>Any idea why am i getting  <code>topology destroyed</code> error ?
  Please help.</p>