chore: init

This commit is contained in:
Kuizuo
2024-04-26 02:12:44 +08:00
commit 5231e5f565
298 changed files with 44435 additions and 0 deletions
+5
View File
@@ -0,0 +1,5 @@
import { getExtendedPrismaClient } from '@server/shared/database/prisma.extension'
export const prisma = getExtendedPrismaClient({
url: process.env.DATABASE_URL,
})
+20
View File
@@ -0,0 +1,20 @@
import { Prisma } from 'database'
import { prisma } from './prisma'
export default async () => {
await prisma.$transaction(async (c) => {
const tasks = [] as Promise<any>[]
const allNames = [] as string[]
Prisma.dmmf.datamodel.models.forEach((model) => {
allNames.push(model.name[0].toLowerCase() + model.name.slice(1))
})
for (const key of allNames) {
if (key.startsWith('$'))
continue
tasks.push(c[key].deleteMany())
}
await Promise.all(tasks)
})
}