Browse Source

fix(nocodb): bulk delete logic

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

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

@ -2206,22 +2206,25 @@ class BaseModelSqlv2 {
transaction = await this.dbDriver.transaction();
const deleted = [];
const deletePkValues = [];
const res = [];
for (const d of deleteIds) {
await this.validate(d);
const pkValues = await this._extractPksValues(d);
if (!pkValues) {
// pk not specified - bypass
continue;
}
deleted.push(await this.readByPk(pkValues));
deletePkValues.push(pkValues);
await transaction(this.tnPath).del().where(d);
res.push(d);
}
await transaction.commit();
for (const pkValues of deletePkValues) {
deleted.push(await this.readByPk(pkValues));
}
await this.afterBulkDelete(deleted, this.dbDriver, cookie);
return res;

Loading…
Cancel
Save