wip fix
This commit is contained in:
parent
05b58b369b
commit
f8afc41afb
|
|
@ -14,31 +14,35 @@ 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[];
|
||||||
|
|
||||||
try {
|
const b = table || batch;
|
||||||
for (const item of batch) {
|
|
||||||
if (
|
if (b) {
|
||||||
item.table &&
|
try {
|
||||||
Object.entries(item.where).length > 0 &&
|
for (const item of b) {
|
||||||
Object.entries(item.data).length > 0
|
if (
|
||||||
) {
|
item.table &&
|
||||||
const tableInstance = prisma[item.table];
|
Object.entries(item.where).length > 0 &&
|
||||||
if (tableInstance) {
|
Object.entries(item.data).length > 0
|
||||||
promises.push(
|
) {
|
||||||
tableInstance.updateMany({ where: item.where, data: item.data })
|
const tableInstance = prisma[item.table];
|
||||||
);
|
if (tableInstance) {
|
||||||
|
promises.push(
|
||||||
|
tableInstance.updateMany({ where: item.where, data: item.data })
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
await Promise.all(promises);
|
||||||
|
} catch (e: any) {
|
||||||
|
throw new Error(e.message);
|
||||||
}
|
}
|
||||||
await Promise.all(promises);
|
|
||||||
} catch (e: any) {
|
|
||||||
throw new Error(e.message);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue