Browse Source

fix: pass right props

Signed-off-by: Pranav C <pranavxc@gmail.com>
pull/5901/head
Pranav C 2 years ago
parent
commit
e98abee167
  1. 20
      packages/nocodb/src/services/data-table.service.ts

20
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<string,any> | Record<string,any>[]; model: Model }) {
const pkColumns = await model.getColumns().then((cols) => cols.filter((col) => col.pk));
private async extractIdObj({
model,
body,
}: {
body: Record<string, any> | Record<string, any>[];
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) => {
acc[col.title] = row[col.title];
return acc;
})
})
});
});
return Array.isArray(body) ? result : result[0];
}

Loading…
Cancel
Save