Skip to content

Commit cfe208c

Browse files
feat(getDbInstance): Added getDbInstance method
Signed-off-by: BorntraegerMarc <[email protected]>
1 parent fafca06 commit cfe208c

File tree

2 files changed

+27
-0
lines changed

2 files changed

+27
-0
lines changed

index.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,16 @@ var MongodbDriver = Base.extend({
213213
return this._run('insert', this.internals.seedTable, {name: name, run_on: new Date()})
214214
.nodeify(callback);
215215
},
216+
217+
/**
218+
* Returns the DB instance so custom updates can be made
219+
*
220+
* @param callback
221+
*/
222+
getDbInstance: function (callback) {
223+
return this._run('getDbInstance', null, {run_on: new Date()})
224+
.nodeify(callback);
225+
},
216226

217227
/**
218228
* Runs a query
@@ -345,6 +355,9 @@ var MongodbDriver = Base.extend({
345355
case 'updateMany':
346356
db.collection(collection)[command](options.query, options.update, options.options, callbackFunction);
347357
break;
358+
case 'getDbInstance':
359+
callbackFunction(null, db);
360+
break;
348361
default:
349362
db[command](collection, callbackFunction);
350363
break;

test/mongodb_test.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -468,4 +468,18 @@ vows
468468
}
469469
}
470470
})
471+
.addBatch({
472+
getDbInstance: {
473+
topic: function() {
474+
db.getDbInstance(this.callback);
475+
},
476+
477+
teardown: function() {
478+
},
479+
480+
"has database reference": function(err, db) {
481+
assert.isNotNull(db);
482+
}
483+
}
484+
})
471485
.export(module);

0 commit comments

Comments
 (0)