Tidy up datasource

This commit is contained in:
Raymond Feng 2018-05-02 16:22:06 -07:00
parent 1ef38a6929
commit cc99cd8f0f
1 changed files with 3 additions and 1 deletions

View File

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