Ability to transparently close connection with database
This commit is contained in:
parent
182f3ff12e
commit
8b6c608c6c
|
@ -153,6 +153,10 @@ MongooseAdapter.prototype.updateAttributes = function updateAttrs(model, id, dat
|
|||
});
|
||||
};
|
||||
|
||||
MongooseAdapter.prototype.disconnect = function () {
|
||||
this.client.connection.close();
|
||||
};
|
||||
|
||||
function merge(base, update) {
|
||||
Object.keys(update).forEach(function (key) {
|
||||
base[key] = update[key];
|
||||
|
|
|
@ -191,3 +191,7 @@ BridgeToRedis.prototype.updateAttributes = function updateAttrs(model, id, data,
|
|||
}.bind(this));
|
||||
};
|
||||
|
||||
BridgeToRedis.prototype.disconnect = function disconnect() {
|
||||
this.client.quit();
|
||||
};
|
||||
|
||||
|
|
|
@ -153,6 +153,12 @@ Schema.prototype.defineForeignKey = function defineForeignKey(className, key) {
|
|||
}
|
||||
};
|
||||
|
||||
Schema.prototype.disconnect = function disconnect() {
|
||||
if (typeof this.adapter.disconnect === 'function') {
|
||||
this.adapter.disconnect();
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
function hiddenProperty(where, property, value) {
|
||||
Object.defineProperty(where, property, {
|
||||
|
|
|
@ -341,6 +341,7 @@ function testOrm(schema) {
|
|||
});
|
||||
|
||||
function allTestsDone() {
|
||||
schema.disconnect();
|
||||
console.log('Test done in %dms\n', Date.now() - start);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue