From a9613561633263ec3225c216599ed0287ac2ef33 Mon Sep 17 00:00:00 2001 From: Dmitry Patsura Date: Fri, 29 Jun 2018 17:40:11 +0900 Subject: [PATCH 1/2] Feature: Allow to pass additional options for run('createIndex') Signed-off-by: Dmitry Patsura --- index.js | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/index.js b/index.js index abdd8cd..064eaa9 100755 --- a/index.js +++ b/index.js @@ -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: { + indexName: indexName, + unique: unique + } }; - return this._run('createIndex', collectionName, options) + return this._run('createIndex', collectionName, parameters) .nodeify(callback); }, @@ -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 @@ -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); From 1b0068da37e92c92b8614e09a139cbb41162462b Mon Sep 17 00:00:00 2001 From: Dmitry Patsura Date: Tue, 3 Jul 2018 16:48:08 +0900 Subject: [PATCH 2/2] Fix: Use name instead of indexName for options on createIndex call Signed-off-by: Dmitry Patsura --- index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.js b/index.js index 064eaa9..9d773ba 100755 --- a/index.js +++ b/index.js @@ -161,7 +161,7 @@ var MongodbDriver = Base.extend({ var parameters = { columns: columns, options: { - indexName: indexName, + name: indexName, unique: unique } };