|
|
@ -3974,6 +3974,15 @@ class BaseModelSqlv2 { |
|
|
|
{ raw: true }, |
|
|
|
{ raw: true }, |
|
|
|
); |
|
|
|
); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
await this.updateLastModifiedTime({ |
|
|
|
|
|
|
|
model: parentTable, |
|
|
|
|
|
|
|
rowIds: [childId], |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
await this.updateLastModifiedTime({ |
|
|
|
|
|
|
|
model: childTable, |
|
|
|
|
|
|
|
rowIds: [rowId], |
|
|
|
|
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
break; |
|
|
|
break; |
|
|
|
case RelationTypes.HAS_MANY: |
|
|
|
case RelationTypes.HAS_MANY: |
|
|
@ -3993,6 +4002,11 @@ class BaseModelSqlv2 { |
|
|
|
null, |
|
|
|
null, |
|
|
|
{ raw: true }, |
|
|
|
{ raw: true }, |
|
|
|
); |
|
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
await this.updateLastModifiedTime({ |
|
|
|
|
|
|
|
model: parentTable, |
|
|
|
|
|
|
|
rowIds: [rowId], |
|
|
|
|
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
break; |
|
|
|
break; |
|
|
|
case RelationTypes.BELONGS_TO: |
|
|
|
case RelationTypes.BELONGS_TO: |
|
|
@ -4012,6 +4026,11 @@ class BaseModelSqlv2 { |
|
|
|
null, |
|
|
|
null, |
|
|
|
{ raw: true }, |
|
|
|
{ raw: true }, |
|
|
|
); |
|
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
await this.updateLastModifiedTime({ |
|
|
|
|
|
|
|
model: parentTable, |
|
|
|
|
|
|
|
rowIds: [childId], |
|
|
|
|
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
break; |
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
@ -4105,6 +4124,15 @@ class BaseModelSqlv2 { |
|
|
|
null, |
|
|
|
null, |
|
|
|
{ raw: true }, |
|
|
|
{ raw: true }, |
|
|
|
); |
|
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
await this.updateLastModifiedTime({ |
|
|
|
|
|
|
|
model: parentTable, |
|
|
|
|
|
|
|
rowIds: [childId], |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
await this.updateLastModifiedTime({ |
|
|
|
|
|
|
|
model: childTable, |
|
|
|
|
|
|
|
rowIds: [rowId], |
|
|
|
|
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
break; |
|
|
|
break; |
|
|
|
case RelationTypes.HAS_MANY: |
|
|
|
case RelationTypes.HAS_MANY: |
|
|
@ -4122,6 +4150,11 @@ class BaseModelSqlv2 { |
|
|
|
null, |
|
|
|
null, |
|
|
|
{ raw: true }, |
|
|
|
{ raw: true }, |
|
|
|
); |
|
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
await this.updateLastModifiedTime({ |
|
|
|
|
|
|
|
model: parentTable, |
|
|
|
|
|
|
|
rowIds: [rowId], |
|
|
|
|
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
break; |
|
|
|
break; |
|
|
|
case RelationTypes.BELONGS_TO: |
|
|
|
case RelationTypes.BELONGS_TO: |
|
|
@ -4139,6 +4172,11 @@ class BaseModelSqlv2 { |
|
|
|
null, |
|
|
|
null, |
|
|
|
{ raw: true }, |
|
|
|
{ raw: true }, |
|
|
|
); |
|
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
await this.updateLastModifiedTime({ |
|
|
|
|
|
|
|
model: parentTable, |
|
|
|
|
|
|
|
rowIds: [childId], |
|
|
|
|
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
break; |
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
@ -5048,6 +5086,15 @@ class BaseModelSqlv2 { |
|
|
|
await this.execAndParse(this.dbDriver(vTn).insert(insertData), null, { |
|
|
|
await this.execAndParse(this.dbDriver(vTn).insert(insertData), null, { |
|
|
|
raw: true, |
|
|
|
raw: true, |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
await this.updateLastModifiedTime({ |
|
|
|
|
|
|
|
model: parentTable, |
|
|
|
|
|
|
|
rowIds: childIds, |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
await this.updateLastModifiedTime({ |
|
|
|
|
|
|
|
model: childTable, |
|
|
|
|
|
|
|
rowIds: [rowId], |
|
|
|
|
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
break; |
|
|
|
break; |
|
|
|
case RelationTypes.HAS_MANY: |
|
|
|
case RelationTypes.HAS_MANY: |
|
|
@ -5122,6 +5169,11 @@ class BaseModelSqlv2 { |
|
|
|
); |
|
|
|
); |
|
|
|
} |
|
|
|
} |
|
|
|
await this.execAndParse(updateQb, null, { raw: true }); |
|
|
|
await this.execAndParse(updateQb, null, { raw: true }); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
await this.updateLastModifiedTime({ |
|
|
|
|
|
|
|
model: parentTable, |
|
|
|
|
|
|
|
rowIds: [rowId], |
|
|
|
|
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
break; |
|
|
|
break; |
|
|
|
case RelationTypes.BELONGS_TO: |
|
|
|
case RelationTypes.BELONGS_TO: |
|
|
@ -5164,6 +5216,11 @@ class BaseModelSqlv2 { |
|
|
|
null, |
|
|
|
null, |
|
|
|
{ raw: true }, |
|
|
|
{ raw: true }, |
|
|
|
); |
|
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
await this.updateLastModifiedTime({ |
|
|
|
|
|
|
|
model: parentTable, |
|
|
|
|
|
|
|
rowIds: [rowId], |
|
|
|
|
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
break; |
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
@ -5305,6 +5362,15 @@ class BaseModelSqlv2 { |
|
|
|
: childIds, |
|
|
|
: childIds, |
|
|
|
); |
|
|
|
); |
|
|
|
await this.execAndParse(delQb, null, { raw: true }); |
|
|
|
await this.execAndParse(delQb, null, { raw: true }); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
await this.updateLastModifiedTime({ |
|
|
|
|
|
|
|
model: parentTable, |
|
|
|
|
|
|
|
rowIds: childIds, |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
await this.updateLastModifiedTime({ |
|
|
|
|
|
|
|
model: childTable, |
|
|
|
|
|
|
|
rowIds: [rowId], |
|
|
|
|
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
break; |
|
|
|
break; |
|
|
|
case RelationTypes.HAS_MANY: |
|
|
|
case RelationTypes.HAS_MANY: |
|
|
@ -5385,6 +5451,11 @@ class BaseModelSqlv2 { |
|
|
|
null, |
|
|
|
null, |
|
|
|
{ raw: true }, |
|
|
|
{ raw: true }, |
|
|
|
); |
|
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
await this.updateLastModifiedTime({ |
|
|
|
|
|
|
|
model: parentTable, |
|
|
|
|
|
|
|
rowIds: [rowId], |
|
|
|
|
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
break; |
|
|
|
break; |
|
|
|
case RelationTypes.BELONGS_TO: |
|
|
|
case RelationTypes.BELONGS_TO: |
|
|
@ -5430,6 +5501,11 @@ class BaseModelSqlv2 { |
|
|
|
null, |
|
|
|
null, |
|
|
|
{ raw: true }, |
|
|
|
{ raw: true }, |
|
|
|
); |
|
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
await this.updateLastModifiedTime({ |
|
|
|
|
|
|
|
model: parentTable, |
|
|
|
|
|
|
|
rowIds: [childIds[0]], |
|
|
|
|
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
break; |
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
@ -5515,14 +5591,21 @@ class BaseModelSqlv2 { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
async updateLastModifiedTime({ rowIds }: { rowIds: any | any[] }) { |
|
|
|
async updateLastModifiedTime({ |
|
|
|
|
|
|
|
rowIds, |
|
|
|
|
|
|
|
model = this.model, |
|
|
|
|
|
|
|
knex = this.dbDriver, |
|
|
|
|
|
|
|
}: { |
|
|
|
|
|
|
|
rowIds: any | any[]; |
|
|
|
|
|
|
|
model?: Model; |
|
|
|
|
|
|
|
}) { |
|
|
|
const columnName = 'updated_at'; |
|
|
|
const columnName = 'updated_at'; |
|
|
|
|
|
|
|
|
|
|
|
const qb = this.dbDriver(this.tnPath).update({ |
|
|
|
const qb = knex(model.table_name).update({ |
|
|
|
[columnName]: this.dbDriver.fn.now(), |
|
|
|
[columnName]: this.dbDriver.fn.now(), |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
for(const rowId of rowIds) { |
|
|
|
for (const rowId of Array.isArray(rowIds) ? rowIds : [rowIds]) { |
|
|
|
qb.orWhere(await this._wherePk(rowId)); |
|
|
|
qb.orWhere(await this._wherePk(rowId)); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|