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