Browse Source

Add check for cb undefined to prevent calls to ensureIndex with index field and options given but without cb throw an error

saintedlama/travis-non-legacy
saintedlama 9 years ago
parent
commit
9eae343f41
  1. 2
      lib/collection.js

2
lib/collection.js

@ -183,6 +183,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);
opts.name = indexName(index);
opts.key = index;
this.runCommand('createIndexes', {indexes: [opts]}, cb);

Loading…
Cancel
Save