Skip to content

Commit

Permalink
Fix schema=>adapter promisified calls
Browse files Browse the repository at this point in the history
  • Loading branch information
1602 committed Jul 21, 2016
1 parent 307ea2e commit 0caf74a
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions lib/schema.js
Expand Up @@ -169,6 +169,7 @@ function Schema(name, settings) {
if ('function' !== typeof adapterMethod) {
throw new Error('Adapted does not support "' + method + '" method');
}

var cb = args[args.length - 1];
var retval = adapterMethod.apply(schema.adapter, args);

Expand All @@ -177,6 +178,8 @@ function Schema(name, settings) {
.then(function(res) { cb(null, res); })
.catch(function(err) { cb(err); });
}

return retval;
};

}
Expand Down Expand Up @@ -473,7 +476,7 @@ Schema.prototype.automigrate = function (cb) {
Schema.prototype.autoupdate = function (cb) {
this.freeze();
if (this.adapter.autoupdate) {
this.callAdapter('autoupdate', cb);
return this.callAdapter('autoupdate', cb);
} else if (cb) {
cb();
}
Expand All @@ -486,7 +489,7 @@ Schema.prototype.autoupdate = function (cb) {
Schema.prototype.isActual = function (cb) {
this.freeze();
if (this.adapter.isActual) {
this.callAdapter('isActual', cb);
return this.callAdapter('isActual', cb);
} else if (cb) {
cb(null, undefined);
}
Expand Down

0 comments on commit 0caf74a

Please sign in to comment.