Safe connect call

This commit is contained in:
Anatoliy Chakkaev 2013-04-22 16:22:20 +04:00 committed by Raymond Feng
parent 23004c12c1
commit 8370538e4e
1 changed files with 14 additions and 10 deletions

View File

@ -122,6 +122,7 @@ function Schema(name, settings) {
schema.connect = function(cb) {
var schema = this;
schema.connecting = true;
if (schema.adapter.connect) {
schema.adapter.connect(function(err) {
if (!err) {
schema.connected = true;
@ -132,6 +133,9 @@ function Schema(name, settings) {
cb(err);
}
});
} else {
process.nextTick(cb);
}
};
};