From e98abee16736f7433c857d626a63c93a70d2ef8a Mon Sep 17 00:00:00 2001 From: Pranav C Date: Tue, 30 May 2023 13:10:44 +0530 Subject: [PATCH] fix: pass right props Signed-off-by: Pranav C --- .../nocodb/src/services/data-table.service.ts | 22 +++++++++++++------ 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/packages/nocodb/src/services/data-table.service.ts b/packages/nocodb/src/services/data-table.service.ts index d3ca4aada6..020d3fa77f 100644 --- a/packages/nocodb/src/services/data-table.service.ts +++ b/packages/nocodb/src/services/data-table.service.ts @@ -97,7 +97,7 @@ export class DataTableService { { cookie: param.cookie }, ); - return this.extractIdObj(param.body) + return this.extractIdObj({ body: param.body, model }); } async dataDelete(param: { @@ -121,7 +121,7 @@ export class DataTableService { { cookie: param.cookie }, ); - return this.extractIdObj(param.body); + return this.extractIdObj({ body: param.body, model }); } async dataCount(param: { @@ -177,15 +177,23 @@ export class DataTableService { return { model, view }; } - private async extractIdObj({ model, body }: { body: Record | Record[]; model: Model }) { - const pkColumns = await model.getColumns().then((cols) => cols.filter((col) => col.pk)); + private async extractIdObj({ + model, + body, + }: { + body: Record | Record[]; + model: Model; + }) { + const pkColumns = await model + .getColumns() + .then((cols) => cols.filter((col) => col.pk)); const result = (Array.isArray(body) ? body : [body]).map((row) => { - return pkColumns.reduce((acc, col) => { + return pkColumns.reduce((acc, col) => { acc[col.title] = row[col.title]; return acc; - }) - }) + }); + }); return Array.isArray(body) ? result : result[0]; }