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(); transaction = await this.dbDriver.transaction();
const deleted = []; const deleted = [];
const deletePkValues = [];
const res = []; const res = [];
for (const d of deleteIds) { for (const d of deleteIds) {
await this.validate(d);
const pkValues = await this._extractPksValues(d); const pkValues = await this._extractPksValues(d);
if (!pkValues) { if (!pkValues) {
// pk not specified - bypass // pk not specified - bypass
continue; continue;
} }
deletePkValues.push(pkValues);
deleted.push(await this.readByPk(pkValues));
await transaction(this.tnPath).del().where(d); await transaction(this.tnPath).del().where(d);
res.push(d); res.push(d);
} }
await transaction.commit(); await transaction.commit();
for (const pkValues of deletePkValues) {
deleted.push(await this.readByPk(pkValues));
}
await this.afterBulkDelete(deleted, this.dbDriver, cookie); await this.afterBulkDelete(deleted, this.dbDriver, cookie);
return res; return res;

Loading…
Cancel
Save