Skip to content

Commit ae2c522

Browse files
committed
Feature: Allow to pass additional options for run('createIndex')
Signed-off-by: Dmitry Patsura <[email protected]>
1 parent 1ff0509 commit ae2c522

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

index.js

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -158,13 +158,15 @@ var MongodbDriver = Base.extend({
158158
*/
159159
addIndex: function(collectionName, indexName, columns, unique, callback) {
160160

161-
var options = {
162-
indexName: indexName,
161+
var parameters = {
163162
columns: columns,
164-
unique: unique
163+
options: {
164+
indexName: indexName,
165+
unique: unique
166+
}
165167
};
166168

167-
return this._run('createIndex', collectionName, options)
169+
return this._run('createIndex', collectionName, parameters)
168170
.nodeify(callback);
169171
},
170172

@@ -213,7 +215,7 @@ var MongodbDriver = Base.extend({
213215
return this._run('insert', this.internals.seedTable, {name: name, run_on: new Date()})
214216
.nodeify(callback);
215217
},
216-
218+
217219
/**
218220
* Returns the DB instance so custom updates can be made.
219221
* NOTE: This method exceptionally does not call close() on the database driver when the promise resolves. So the getDbInstance method caller
@@ -322,8 +324,8 @@ var MongodbDriver = Base.extend({
322324
case 'renameCollection':
323325
db[command](collection, options.newCollection, callbackFunction);
324326
break;
325-
case 'createIndex':
326-
db[command](collection, options.columns, {name: options.indexName, unique: options.unique}, callbackFunction);
327+
case 'createIndex':
328+
db[command](collection, options.columns, options.options, callbackFunction);
327329
break;
328330
case 'dropIndex':
329331
db.collection(collection)[command](options.indexName, callbackFunction);

0 commit comments

Comments
 (0)