Permalink
Browse files

Safe connect call

  • Loading branch information...
1 parent 7d3b1c4 commit 0419057547fdd01ddcf898bb578cda687b826178 @1602 committed Apr 22, 2013
Showing with 14 additions and 10 deletions.
  1. +14 −10 lib/schema.js
View
@@ -122,16 +122,20 @@ function Schema(name, settings) {
schema.connect = function(cb) {
var schema = this;
schema.connecting = true;
- schema.adapter.connect(function(err) {
- if (!err) {
- schema.connected = true;
- schema.connecting = false;
- schema.emit('connected');
- }
- if (cb) {
- cb(err);
- }
- });
+ if (schema.adapter.connect) {
+ schema.adapter.connect(function(err) {
+ if (!err) {
+ schema.connected = true;
+ schema.connecting = false;
+ schema.emit('connected');
+ }
+ if (cb) {
+ cb(err);
+ }
+ });
+ } else {
+ process.nextTick(cb);
+ }
};
};

0 comments on commit 0419057

Please sign in to comment.