

export const MiniMongo = {}

if (global.Mongo) {
  MiniMongo.Collection = class MiniMongoCollection extends global.Mongo.Collection {
    constructor(name) {
      super(null)   // null causes this to be a MiniMongo
      this.collectionName = name
    }

    _ensureIndex() {
      // Don't do anything but don't throw as MiniMongo normally would
      // REVISIT: if this was ever used on the client it should throw still
    }
  }
}



export const MiniMongo = {}

const NAME_TO_CAUSE_MINIMONGO = null

if (global.Mongo) {
  MiniMongo.Collection = class MiniMongoCollection extends global.Mongo.Collection {
    constructor(name) {
      super(NAME_TO_CAUSE_MINIMONGO)
      this._name = name   // eslint-disable-line no-underscore-dangle
      this.indexes = []
    }

    _ensureIndex(keys, options) {
      this.indexes.push({ keys, options })
      // MiniMongo would normally throw an exception but we ignore it
      // If this was ever used on the client it should throw still
    }
  }
}

Switch to _name for MiniMongo.Collection name to mimick production, store indexes created
Switch to _name for MiniMongo.Collection name to mimick production, store indexes created
