Browse Source

feat(nocodb): use rows_inserted for bulk insert

pull/5349/head
Wing-Kam Wong 2 years ago
parent
commit
57d1b9ec3d
  1. 6
      packages/nocodb/src/lib/meta/helpers/populateSamplePayload.ts
  2. 9
      packages/nocodb/src/lib/meta/helpers/webhookHelpers.ts

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

@ -95,7 +95,11 @@ export async function populateSamplePayloadV2(
samplePayload.data = {
...samplePayload.data,
...(prevRows && { previous_rows: [prevRows] }),
...(rows && { rows: [rows] }),
...(operation !== 'bulkInsert' && rows && { rows: [rows] }),
...(operation === 'bulkInsert' &&
rows && {
row_inserted: 10,
}),
};
return samplePayload;

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

@ -151,7 +151,14 @@ export function constructWebHookData(hook, model, view, prevData, newData) {
...(prevData && {
previous_rows: [prevData],
}),
...(newData && { rows: [newData] }),
...(hook.operation !== 'bulkInsert' && newData && { rows: [newData] }),
...(hook.operation === 'bulkInsert' && {
rows_inserted: Array.isArray(newData)
? newData.length
: newData
? 1
: 0,
}),
},
};
}

Loading…
Cancel
Save