wip fix
This commit is contained in:
parent
4ac633d4a2
commit
05b58b369b
|
|
@ -14,30 +14,31 @@ export const execQuery = async (args: DBArg, prisma: any) => {
|
|||
const { table, action, params } = args;
|
||||
|
||||
if (action === "batch_update") {
|
||||
const { table, batch } = params as unknown as {
|
||||
const { batch } = params as unknown as {
|
||||
table: string;
|
||||
batch: { data: any; where: any }[];
|
||||
batch: { table: string; data: any; where: any }[];
|
||||
};
|
||||
|
||||
const promises = [] as any[];
|
||||
|
||||
const tableInstance = prisma[table];
|
||||
if (tableInstance) {
|
||||
try {
|
||||
for (const item of batch) {
|
||||
if (
|
||||
Object.entries(item.where).length > 0 &&
|
||||
Object.entries(item.data).length > 0
|
||||
) {
|
||||
try {
|
||||
for (const item of batch) {
|
||||
if (
|
||||
item.table &&
|
||||
Object.entries(item.where).length > 0 &&
|
||||
Object.entries(item.data).length > 0
|
||||
) {
|
||||
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;
|
||||
|
|
|
|||
Loading…
Reference in New Issue