From 57d1b9ec3dde59ea825b16f5a64953ea5c5174b4 Mon Sep 17 00:00:00 2001 From: Wing-Kam Wong Date: Wed, 29 Mar 2023 19:38:10 +0800 Subject: [PATCH] feat(nocodb): use rows_inserted for bulk insert --- .../nocodb/src/lib/meta/helpers/populateSamplePayload.ts | 6 +++++- packages/nocodb/src/lib/meta/helpers/webhookHelpers.ts | 9 ++++++++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/packages/nocodb/src/lib/meta/helpers/populateSamplePayload.ts b/packages/nocodb/src/lib/meta/helpers/populateSamplePayload.ts index f6c117943a..b1e9073710 100644 --- a/packages/nocodb/src/lib/meta/helpers/populateSamplePayload.ts +++ b/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; diff --git a/packages/nocodb/src/lib/meta/helpers/webhookHelpers.ts b/packages/nocodb/src/lib/meta/helpers/webhookHelpers.ts index 6f27a3e56a..f3e6dbd2a2 100644 --- a/packages/nocodb/src/lib/meta/helpers/webhookHelpers.ts +++ b/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, + }), }, }; }