diff --git a/lib/datasource.js b/lib/datasource.js index 08c82644..cb9e96fb 100644 --- a/lib/datasource.js +++ b/lib/datasource.js @@ -165,7 +165,7 @@ function DataSource(name, settings, modelBuilder) { }.bind(this)); // define DataAccessObject.prototype methods - Object.keys(dao.prototype).forEach(function(name) { + Object.keys(dao.prototype || []).forEach(function(name) { var fn = dao.prototype[name]; this.DataAccessObject.prototype[name] = fn; if (typeof fn === 'function') { @@ -2541,6 +2541,7 @@ DataSource.prototype.ready = function(obj, args) { * @param {Function} [cb] Callback function */ DataSource.prototype.ping = function(cb) { + cb = cb || utils.createPromiseCallback(); var self = this; if (self.connector.ping) { this.connector.ping(cb); @@ -2552,6 +2553,7 @@ DataSource.prototype.ping = function(cb) { cb(err); }); } + return cb.promise; }; /*! The hidden property call is too expensive so it is not used that much