Browse Source

refactor(nocodb): bulkUpdateAll logic

pull/5349/head
Wing-Kam Wong 2 years ago
parent
commit
a6eb67b4be
  1. 16
      packages/nocodb/src/lib/db/sql-data-mapper/lib/sql/BaseModelSqlv2.ts

16
packages/nocodb/src/lib/db/sql-data-mapper/lib/sql/BaseModelSqlv2.ts

@ -2003,7 +2003,7 @@ class BaseModelSqlv2 {
data,
{ cookie }: { cookie?: any } = {}
) {
let queryResponse;
let res = [];
try {
const updateData = await this.model.mapAliasToColumn(data);
await this.validate(updateData);
@ -2035,13 +2035,19 @@ class BaseModelSqlv2 {
);
qb.update(updateData);
queryResponse = (await qb) as any;
if (this.isPg || this.isMssql) {
qb.returning(
`${this.model.primaryKey.column_name} as ${this.model.primaryKey.title}`
);
}
const count = queryResponse ?? 0;
await this.afterBulkUpdate(queryResponse, this.dbDriver, cookie);
res = (await qb) as any;
}
return count;
await this.afterBulkUpdate(res, this.dbDriver, cookie);
return res.length;
} catch (e) {
throw e;
}

Loading…
Cancel
Save