Browse Source

fix: upsert detection

nc-feat/extensions
mertmit 8 months ago
parent
commit
f0cb3260ca
  1. 8
      packages/nc-gui/composables/useExtensionHelper.ts

8
packages/nc-gui/composables/useExtensionHelper.ts

@ -151,17 +151,19 @@ const [useProvideExtensionHelper, useExtensionHelper] = useInjectionState((exten
insert.push(
...chunk.filter(
(record: Record<string, any>) =>
!list.some((r: Record<string, any>) => r[upsertField.title!] === record[upsertField.title!]),
!list.some((r: Record<string, any>) => `${r[upsertField.title!]}` === `${record[upsertField.title!]}`),
),
)
update.push(
...chunk
.filter((record: Record<string, any>) =>
list.some((r: Record<string, any>) => r[upsertField.title!] === record[upsertField.title!]),
list.some((r: Record<string, any>) => `${r[upsertField.title!]}` === `${record[upsertField.title!]}`),
)
.map((record: Record<string, any>) => {
const existingRecord = list.find((r: Record<string, any>) => r[upsertField.title!] === record[upsertField.title!])
const existingRecord = list.find(
(r: Record<string, any>) => `${r[upsertField.title!]}` === `${record[upsertField.title!]}`,
)
return {
...rowPkData(existingRecord!, tableMeta.columns!),
...record,

Loading…
Cancel
Save