Skip to content

Feature: Allow to pass additional options for run('createIndex') #30

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 8 additions & 6 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -158,13 +158,15 @@ var MongodbDriver = Base.extend({
*/
addIndex: function(collectionName, indexName, columns, unique, callback) {

var options = {
indexName: indexName,
var parameters = {
columns: columns,
unique: unique
options: {
name: indexName,
unique: unique
}
};

return this._run('createIndex', collectionName, options)
return this._run('createIndex', collectionName, parameters)
.nodeify(callback);
},

Expand Down Expand Up @@ -213,7 +215,7 @@ var MongodbDriver = Base.extend({
return this._run('insert', this.internals.seedTable, {name: name, run_on: new Date()})
.nodeify(callback);
},

/**
* Returns the DB instance so custom updates can be made.
* NOTE: This method exceptionally does not call close() on the database driver when the promise resolves. So the getDbInstance method caller
Expand Down Expand Up @@ -323,7 +325,7 @@ var MongodbDriver = Base.extend({
db[command](collection, options.newCollection, callbackFunction);
break;
case 'createIndex':
db[command](collection, options.columns, {name: options.indexName, unique: options.unique}, callbackFunction);
db[command](collection, options.columns, options.options, callbackFunction);
break;
case 'dropIndex':
db.collection(collection)[command](options.indexName, callbackFunction);
Expand Down