diff --git a/lib/schema.js b/lib/schema.js index 833a3cb3..724df3ac 100644 --- a/lib/schema.js +++ b/lib/schema.js @@ -124,6 +124,7 @@ function Schema(name, settings) { // we have an adaper now? if (!this.adapter) { + this.emit('disconnected'); throw new Error('Adapter "' + name + '" is not defined correctly: it should define `adapter` member of schema synchronously'); } @@ -499,6 +500,7 @@ Schema.prototype.disconnect = function disconnect(cb) { if (typeof this.adapter.disconnect === 'function') { this.connected = false; this.adapter.disconnect(cb); + this.emit('disconnected'); } else if (cb) { cb(); }