docs: function SaveToMongo(opts) {
    if (!(this instanceof SaveToMongo)) return new SaveToMongo(opts);
  
    var options = this.options = opts || {};
  
    // check bulk options
  
    if (options.bulk) {
  
      if (typeof options.bulk !== 'object') {
        throw new TypeError('Option `bulk` must be an object');
      }
  
      if (options.bulk.mode !== 'ordered' && options.bulk.mode !== 'unordered') {
        throw new Error('Option `bulk.mode` must be a string and can be "ordered" or "unordered"');
      }
  
      if (options.bulk.bufferSize && (typeof options.bulk.bufferSize !== 'number' || options.bulk.bufferSize <= 0)) {
        throw new Error('Option `bulk.bufferSize` must be a number greater than 0');
      }
  
    }
  
    this.bulk = options.bulk;
    this.opCounter = options.bulk ? 0 : null;
  
    if (this.bulk && !this.bulk.bufferSize) this.bulk.bufferSize = 1000;
  
    // stream super constructor
  
    Writable.call(this, options.streamOptions || {
      objectMode: true
    });
  
    // handle finish (only if bulk)
  
    this.on('finish', function() {
  
      if (this.bulk && this.opCounter > 0) {
        debug('Executing remaining bulk inserts');
  
        this.executeBulkOps(function(err, result) {
          this._db.close();
          this.emit('done');
        });
  
      } else {
        this._db.close();
        this.emit('done');
      }
  
    });
  
  }