fix
This commit is contained in:
parent
80cf37b006
commit
a19c228028
|
|
@ -17,27 +17,22 @@ export const execQuery = async (args: DBArg, prisma: any) => {
|
||||||
|
|
||||||
if (action === "batch_upsert") {
|
if (action === "batch_upsert") {
|
||||||
const { arg } = params as unknown as {
|
const { arg } = params as unknown as {
|
||||||
arg?: object;
|
arg?: {
|
||||||
|
table: string;
|
||||||
|
where: any;
|
||||||
|
data: any[];
|
||||||
|
mode: "field" | "relation";
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
if (arg) {
|
||||||
const body = (Array.isArray(arg) ? arg[0] : arg) as {
|
const { table, where, data } = arg;
|
||||||
table: string;
|
const mode = arg.mode || "field";
|
||||||
where: any;
|
|
||||||
data: any[];
|
|
||||||
mode: "field" | "relation";
|
|
||||||
};
|
|
||||||
|
|
||||||
if (body) {
|
|
||||||
const { table, where, data } = body;
|
|
||||||
const mode = body.mode || "field";
|
|
||||||
|
|
||||||
if (table && where && data) {
|
if (table && where && data) {
|
||||||
const transactions = [];
|
const transactions = [];
|
||||||
|
|
||||||
const schema_path = dir("app/db/prisma/schema.prisma");
|
const schema_path = dir("app/db/prisma/schema.prisma");
|
||||||
const schema = createPrismaSchemaBuilder(await readAsync(schema_path));
|
const schema = createPrismaSchemaBuilder(await readAsync(schema_path));
|
||||||
const schema_table = schema.findByType("model", { name: table });
|
const schema_table = schema.findByType("model", { name: table });
|
||||||
|
|
||||||
const tables = schema
|
const tables = schema
|
||||||
.findAllByType("model", {})
|
.findAllByType("model", {})
|
||||||
.map((e) => e?.name) as string[];
|
.map((e) => e?.name) as string[];
|
||||||
|
|
@ -55,7 +50,6 @@ export const execQuery = async (args: DBArg, prisma: any) => {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const rels = getRels({ schema_table, schema, table, tables });
|
const rels = getRels({ schema_table, schema, table, tables });
|
||||||
if (pks.length > 0) {
|
if (pks.length > 0) {
|
||||||
if (Object.keys(where.length > 0)) {
|
if (Object.keys(where.length > 0)) {
|
||||||
|
|
@ -168,7 +162,6 @@ export const execQuery = async (args: DBArg, prisma: any) => {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (deletes.length > 0) {
|
if (deletes.length > 0) {
|
||||||
console.log("deletes", deletes);
|
|
||||||
for (const item of deletes) {
|
for (const item of deletes) {
|
||||||
const where = {} as any;
|
const where = {} as any;
|
||||||
for (const pk of pks) {
|
for (const pk of pks) {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue