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
|
||||
*/
|
||||
DataSource.prototype.disconnect = function disconnect(cb) {
|
||||
if (typeof this.adapter.disconnect === 'function') {
|
||||
this.connected = false;
|
||||
this.adapter.disconnect(cb);
|
||||
} else if (cb) {
|
||||
cb();
|
||||
var self = this;
|
||||
if (this.connected && (typeof this.adapter.disconnect === 'function')) {
|
||||
this.adapter.disconnect(function(err, result) {
|
||||
self.connected = false;
|
||||
cb && cb(err, result);
|
||||
});
|
||||
} else {
|
||||
process.nextTick(function() {
|
||||
cb && cb();
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in New Issue