fix mode batch upsert
This commit is contained in:
parent
e23a4a2977
commit
78a4141dc8
|
|
@ -21,7 +21,7 @@ export const execQuery = async (args: DBArg, prisma: any) => {
|
|||
table: string;
|
||||
where: any;
|
||||
data: any[];
|
||||
mode: "field" | "relation";
|
||||
mode: "field" | "raw";
|
||||
};
|
||||
};
|
||||
if (arg) {
|
||||
|
|
@ -89,6 +89,7 @@ export const execQuery = async (args: DBArg, prisma: any) => {
|
|||
}
|
||||
>;
|
||||
|
||||
if (mode !== "raw") {
|
||||
for (const row of data) {
|
||||
for (const [k, v] of Object.entries(row) as any) {
|
||||
const rel = rels[k];
|
||||
|
|
@ -158,6 +159,7 @@ export const execQuery = async (args: DBArg, prisma: any) => {
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const select = {} as any;
|
||||
for (const pk of pks) {
|
||||
|
|
@ -194,7 +196,7 @@ export const execQuery = async (args: DBArg, prisma: any) => {
|
|||
return true;
|
||||
});
|
||||
|
||||
if (mode === "field") {
|
||||
if (mode !== "raw") {
|
||||
for (const [k, v] of Object.entries(row) as any) {
|
||||
const rel = rels[k];
|
||||
if (rel) {
|
||||
|
|
@ -247,7 +249,7 @@ export const execQuery = async (args: DBArg, prisma: any) => {
|
|||
}
|
||||
}
|
||||
|
||||
if (mode === "field") {
|
||||
if (mode !== "raw") {
|
||||
if (found) {
|
||||
updates.push({ ...row, ...where });
|
||||
} else {
|
||||
|
|
|
|||
Loading…
Reference in New Issue