diff --git a/lib/collection.js b/lib/collection.js index 128339b..c948c2c 100644 --- a/lib/collection.js +++ b/lib/collection.js @@ -199,8 +199,8 @@ Collection.prototype.dropIndex = function (index, cb) { Collection.prototype.createIndex = function (index, opts, cb) { if (typeof opts === 'function') return this.createIndex(index, {}, opts) - if (typeof opts === 'undefined') return this.createIndex(index, {}, noop) - if (typeof cb === 'undefined') return this.createIndex(index, opts, noop) + if (!opts) return this.createIndex(index, {}, noop) + if (!cb) return this.createIndex(index, opts, noop) this._getCollection(function (err, collection) { if (err) return cb(err) @@ -211,8 +211,8 @@ Collection.prototype.createIndex = function (index, opts, cb) { Collection.prototype.ensureIndex = function (index, opts, cb) { if (typeof opts === 'function') return this.ensureIndex(index, {}, opts) - if (typeof opts === 'undefined') return this.ensureIndex(index, {}, noop) - if (typeof cb === 'undefined') return this.ensureIndex(index, opts, noop) + if (!opts) return this.ensureIndex(index, {}, noop) + if (!cb) return this.ensureIndex(index, opts, noop) this._getCollection(function (err, collection) { if (err) return cb(err)