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

refactor: nonempty array check style

1 parent 6dcb565e
...@@ -768,8 +768,8 @@ class QueryInterface { ...@@ -768,8 +768,8 @@ class QueryInterface {
const model = options.model; const model = options.model;
const primaryKeys = Object.values(model.primaryKeys).map(item => item.field); const primaryKeys = Object.values(model.primaryKeys).map(item => item.field);
const uniqueKeys = Object.values(model.uniqueKeys).filter(c => c.fields.length >= 1).map(c => c.fields); const uniqueKeys = Object.values(model.uniqueKeys).filter(c => c.fields.length > 0).map(c => c.fields);
const indexKeys = Object.values(model._indexes).filter(c => c.unique && c.fields.length >= 1).map(c => c.fields); const indexKeys = Object.values(model._indexes).filter(c => c.unique && c.fields.length > 0).map(c => c.fields);
options.type = QueryTypes.UPSERT; options.type = QueryTypes.UPSERT;
options.updateOnDuplicate = Object.keys(updateValues); options.updateOnDuplicate = Object.keys(updateValues);
......
...@@ -2692,7 +2692,7 @@ class Model { ...@@ -2692,7 +2692,7 @@ class Model {
} }
} }
const firstUniqueKey = Object.values(model.uniqueKeys).find(c => c.fields.length >= 1); const firstUniqueKey = Object.values(model.uniqueKeys).find(c => c.fields.length > 0);
if (firstUniqueKey && firstUniqueKey.fields) { if (firstUniqueKey && firstUniqueKey.fields) {
upsertKeys.push(...firstUniqueKey.fields); upsertKeys.push(...firstUniqueKey.fields);
...@@ -3848,10 +3848,10 @@ class Model { ...@@ -3848,10 +3848,10 @@ class Model {
const now = Utils.now(this.sequelize.options.dialect); const now = Utils.now(this.sequelize.options.dialect);
let updatedAtAttr = this.constructor._timestampAttributes.updatedAt; let updatedAtAttr = this.constructor._timestampAttributes.updatedAt;
if (updatedAtAttr && options.fields.length >= 1 && !options.fields.includes(updatedAtAttr)) { if (updatedAtAttr && options.fields.length > 0 && !options.fields.includes(updatedAtAttr)) {
options.fields.push(updatedAtAttr); options.fields.push(updatedAtAttr);
} }
if (versionAttr && options.fields.length >= 1 && !options.fields.includes(versionAttr)) { if (versionAttr && options.fields.length > 0 && !options.fields.includes(versionAttr)) {
options.fields.push(versionAttr); options.fields.push(versionAttr);
} }
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!