From cc99cd8f0f4c52a449a2e22ce4d7a02f9eed2c02 Mon Sep 17 00:00:00 2001 From: Raymond Feng Date: Wed, 2 May 2018 16:22:06 -0700 Subject: [PATCH] Tidy up datasource --- lib/datasource.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) 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