Browse Source

refactor(nocodb): change deleted_rows to rows

pull/5349/head
Wing-Kam Wong 2 years ago
parent
commit
9b333235ea
  1. 4
      packages/nocodb/src/lib/db/sql-data-mapper/lib/sql/BaseModelSqlv2.ts
  2. 6
      packages/nocodb/src/lib/meta/helpers/populateSamplePayload.ts
  3. 4
      packages/nocodb/src/lib/meta/helpers/webhookHelpers.ts

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

@ -2161,7 +2161,7 @@ class BaseModelSqlv2 {
let noOfDeletedRecords = data;
if (!isBulkAllOperation) {
noOfDeletedRecords = data.length;
await this.handleHooks('after.delete', data, null, req);
await this.handleHooks('after.delete', null, data, req);
}
await Audit.insert({
@ -2256,7 +2256,7 @@ class BaseModelSqlv2 {
ip: req?.clientIp,
user: req?.user?.email,
});
await this.handleHooks('after.delete', data, null, req);
await this.handleHooks('after.delete', null, data, req);
}
private async handleHooks(hookName, prevData, newData, req): Promise<void> {

6
packages/nocodb/src/lib/meta/helpers/populateSamplePayload.ts

@ -94,10 +94,8 @@ export async function populateSamplePayloadV2(
samplePayload.data = {
...samplePayload.data,
...(prevRows && {
[operation === 'delete' ? 'deleted_rows' : 'previous_rows']: [prevRows],
}),
...(operation !== 'delete' && rows && { rows: [rows] }),
...(prevRows && { previous_rows: [prevRows] }),
...(rows && { rows: [rows] }),
};
return samplePayload;

4
packages/nocodb/src/lib/meta/helpers/webhookHelpers.ts

@ -149,9 +149,7 @@ export function constructWebHookData(hook, model, view, prevData, newData) {
view_id: view.id,
view_name: view.title,
...(prevData && {
[hook.operation === 'delete' ? 'deleted_rows' : 'previous_rows']: [
prevData,
],
previous_rows: [prevData],
}),
...(newData && { rows: [newData] }),
},

Loading…
Cancel
Save