不要怂,就是干,撸起袖子干!

Commit 5b771146 by Varga Zsolt Committed by Sushant

refactor(model): use QueryInterface getter (#9126)

1 parent e56a0a05
Showing with 5 additions and 5 deletions
......@@ -2995,9 +2995,9 @@ class Model {
let promise;
if (!options.increment) {
promise = this.sequelize.getQueryInterface().decrement(this, this.getTableName(options), values, where, options);
promise = this.QueryInterface.decrement(this, this.getTableName(options), values, where, options);
} else {
promise = this.sequelize.getQueryInterface().increment(this, this.getTableName(options), values, where, options);
promise = this.QueryInterface.increment(this, this.getTableName(options), values, where, options);
}
return promise.then(affectedRows => {
......@@ -3649,7 +3649,7 @@ class Model {
args = [this, this.constructor.getTableName(options), values, where, options];
}
return this.sequelize.getQueryInterface()[query].apply(this.sequelize.getQueryInterface(), args)
return this.constructor.QueryInterface[query].apply(this.constructor.QueryInterface, args)
.then(results => {
const result = _.head(results);
const rowsUpdated = results[1];
......@@ -3860,7 +3860,7 @@ class Model {
this.setDataValue(field, values[field]);
return this.sequelize.getQueryInterface().update(
return this.constructor.QueryInterface.update(
this, this.constructor.getTableName(options), values, where, _.defaults({ hooks: false, model: this.constructor }, options)
).then(results => {
const rowsUpdated = results[1];
......@@ -3874,7 +3874,7 @@ class Model {
return _.head(results);
});
} else {
return this.sequelize.getQueryInterface().delete(this, this.constructor.getTableName(options), where, _.assign({ type: QueryTypes.DELETE, limit: null }, options));
return this.constructor.QueryInterface.delete(this, this.constructor.getTableName(options), where, _.assign({ type: QueryTypes.DELETE, limit: null }, options));
}
}).tap(() => {
// Run after hook
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!