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));
// 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