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; let noOfDeletedRecords = data;
if (!isBulkAllOperation) { if (!isBulkAllOperation) {
noOfDeletedRecords = data.length; noOfDeletedRecords = data.length;
await this.handleHooks('after.delete', data, null, req); await this.handleHooks('after.delete', null, data, req);
} }
await Audit.insert({ await Audit.insert({
@ -2256,7 +2256,7 @@ class BaseModelSqlv2 {
ip: req?.clientIp, ip: req?.clientIp,
user: req?.user?.email, 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> { 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 = {
...samplePayload.data, ...samplePayload.data,
...(prevRows && { ...(prevRows && { previous_rows: [prevRows] }),
[operation === 'delete' ? 'deleted_rows' : 'previous_rows']: [prevRows], ...(rows && { rows: [rows] }),
}),
...(operation !== 'delete' && rows && { rows: [rows] }),
}; };
return samplePayload; 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_id: view.id,
view_name: view.title, view_name: view.title,
...(prevData && { ...(prevData && {
[hook.operation === 'delete' ? 'deleted_rows' : 'previous_rows']: [ previous_rows: [prevData],
prevData,
],
}), }),
...(newData && { rows: [newData] }), ...(newData && { rows: [newData] }),
}, },

Loading…
Cancel
Save