diff --git a/bun.lockb b/bun.lockb index e727161..aada896 100755 Binary files a/bun.lockb and b/bun.lockb differ diff --git a/pkgs/package.json b/pkgs/package.json index c71dad5..2c338c0 100644 --- a/pkgs/package.json +++ b/pkgs/package.json @@ -1,22 +1,22 @@ { "name": "pkgs", "dependencies": { + "@mrleebo/prisma-ast": "^0.10.1", "@surfy/multipart-parser": "^1.0.2", - "@swc/core": "^1.3.91", + "@swc/core": "^1.5.7", "@types/mime": "^3.0.2", "@types/unzipper": "^0.10.7", "execa": "^8.0.1", - "rambda": "^9.1.0", "fs-jetpack": "^5.1.0", - "@mrleebo/prisma-ast": "^0.10.1", "lmdb": "^2.8.5", "mime": "^3.0.0", + "parse-multipart-data": "^1.5.0", "pino": "^8.15.3", "pino-pretty": "^10.2.0", "radix3": "^1.1.0", + "rambda": "^9.1.0", + "sharp": "^0.33.2", "typescript": "^5.2.2", - "unzipper": "^0.10.14", - "parse-multipart-data": "^1.5.0", - "sharp": "^0.33.2" + "unzipper": "^0.10.14" } } \ No newline at end of file diff --git a/pkgs/utils/query.ts b/pkgs/utils/query.ts index 9532169..dd351ae 100644 --- a/pkgs/utils/query.ts +++ b/pkgs/utils/query.ts @@ -21,10 +21,12 @@ export const execQuery = async (args: DBArg, prisma: any) => { table: string; where: any; data: any[]; + mode: "field" | "relation"; }; }; if (arg) { const { table, where, data } = arg; + const mode = arg.mode || "field"; if (table && where && data) { const transactions = []; @@ -70,10 +72,18 @@ export const execQuery = async (args: DBArg, prisma: any) => { return true; }); - if (found) { - updates.push({ ...row, ...where }); + if (mode === "field") { + if (found) { + updates.push({ ...row, ...where }); + } else { + inserts.push({ ...row, ...where }); + } } else { - inserts.push({ ...row, ...where }); + if (found) { + updates.push({ ...row }); + } else { + inserts.push({ ...row }); + } } }