Skip to content

Commit 87c8170

Browse files
feat(getDbInstance): Added check before driver is closed when getDbInstance method is called
Signed-off-by: BorntraegerMarc <[email protected]>
1 parent cfe208c commit 87c8170

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

index.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -215,9 +215,11 @@ var MongodbDriver = Base.extend({
215215
},
216216

217217
/**
218-
* Returns the DB instance so custom updates can be made
218+
* Returns the DB instance so custom updates can be made.
219+
* NOTE: This method exceptionally does not call close() on the database driver when the promise resolves. So the getDbInstance method caller
220+
* needs to call .close() on it's own after finish working with the database driver.
219221
*
220-
* @param callback
222+
* @param callback with the database driver as 2nd callback argument
221223
*/
222224
getDbInstance: function (callback) {
223225
return this._run('getDbInstance', null, {run_on: new Date()})
@@ -303,7 +305,9 @@ var MongodbDriver = Base.extend({
303305
}
304306

305307
prCB(null, data);
306-
db.close();
308+
if (command !== 'getDbInstance') {
309+
db.close();
310+
}
307311
};
308312

309313
// Depending on the command, we need to use different mongo methods

0 commit comments

Comments
 (0)