fix query upsert

This commit is contained in:
Rizky 2024-05-10 19:50:09 +07:00
parent 1ea1a21ed2
commit 15d725701d
1 changed files with 4 additions and 2 deletions

View File

@ -70,9 +70,9 @@ export const execQuery = async (args: DBArg, prisma: any) => {
}); });
if (found) { if (found) {
updates.push({...row, ...where}); updates.push({ ...row, ...where });
} else { } else {
inserts.push({...row, ...where}); inserts.push({ ...row, ...where });
} }
} }
@ -98,7 +98,9 @@ export const execQuery = async (args: DBArg, prisma: any) => {
const where = {} as any; const where = {} as any;
for (const pk of pks) { for (const pk of pks) {
where[pk.name] = item[pk.name]; where[pk.name] = item[pk.name];
delete item[pk.name];
} }
transactions.push( transactions.push(
prisma[table].update({ data: item, where }) prisma[table].update({ data: item, where })
); );