This commit is contained in:
Rizky 2024-03-13 15:46:06 +07:00
parent 05b58b369b
commit f8afc41afb
1 changed files with 22 additions and 18 deletions

View File

@ -14,15 +14,18 @@ export const execQuery = async (args: DBArg, prisma: any) => {
const { table, action, params } = args; const { table, action, params } = args;
if (action === "batch_update") { if (action === "batch_update") {
const { batch } = params as unknown as { const { table, batch } = params as unknown as {
table: string; table?: { table: string; data: any; where: any }[];
batch: { table: string; data: any; where: any }[]; batch?: { table: string; data: any; where: any }[];
}; };
const promises = [] as any[]; const promises = [] as any[];
const b = table || batch;
if (b) {
try { try {
for (const item of batch) { for (const item of b) {
if ( if (
item.table && item.table &&
Object.entries(item.where).length > 0 && Object.entries(item.where).length > 0 &&
@ -40,6 +43,7 @@ export const execQuery = async (args: DBArg, prisma: any) => {
} catch (e: any) { } catch (e: any) {
throw new Error(e.message); throw new Error(e.message);
} }
}
return; return;
} }