This commit is contained in:
rizrmd 2024-05-17 17:38:43 +07:00
parent a6a43b4346
commit 22134b76db
2 changed files with 12 additions and 5 deletions

BIN
bun.lockb

Binary file not shown.

View File

@ -1,5 +1,6 @@
import { Property, createPrismaSchemaBuilder } from "@mrleebo/prisma-ast";
import { readAsync } from "fs-jetpack";
//@ts-ignore
import { Prisma } from "../../app/db/db";
import { dir } from "./dir";
import { gunzipAsync } from "./gzip";
@ -326,11 +327,17 @@ export const execQuery = async (args: DBArg, prisma: any) => {
const method = tableInstance[action];
if (method) {
if (
action === "deleteMany" &&
(!params[0] || (params[0] && Object.keys(params[0]).length === 0))
) {
throw new Error("deleteMany without condition is forbidden");
if (action === "deleteMany") {
if (!params[0] || (params[0] && Object.keys(params[0]).length === 0))
throw new Error("deleteMany without condition is forbidden");
if (params[0] && params[0].where) {
const filtered = Object.values(params[0].where).filter(
(e) => e
).length;
if (filtered === 0)
throw new Error("deleteMany without condition is forbidden");
}
}
const result = await method(...params);