Improve connect/disconnect
This commit is contained in:
parent
1bb8047b57
commit
9d74759f90
|
@ -752,11 +752,16 @@ DataSource.prototype.defineForeignKey = function defineForeignKey(className, key
|
||||||
* Close database connection
|
* Close database connection
|
||||||
*/
|
*/
|
||||||
DataSource.prototype.disconnect = function disconnect(cb) {
|
DataSource.prototype.disconnect = function disconnect(cb) {
|
||||||
if (typeof this.adapter.disconnect === 'function') {
|
var self = this;
|
||||||
this.connected = false;
|
if (this.connected && (typeof this.adapter.disconnect === 'function')) {
|
||||||
this.adapter.disconnect(cb);
|
this.adapter.disconnect(function(err, result) {
|
||||||
} else if (cb) {
|
self.connected = false;
|
||||||
cb();
|
cb && cb(err, result);
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
process.nextTick(function() {
|
||||||
|
cb && cb();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue