mirror of
https://github.com/enricoros/big-AGI.git
synced 2026-05-10 21:50:14 -07:00
Relocate Prisma to src/server/prisma
This commit is contained in:
@@ -13,6 +13,9 @@
|
||||
"db:studio": "prisma studio",
|
||||
"vercel:env:pull": "npx vercel env pull .env.development.local"
|
||||
},
|
||||
"prisma": {
|
||||
"schema": "src/server/prisma/schema.prisma"
|
||||
},
|
||||
"dependencies": {
|
||||
"@emotion/cache": "^11.11.0",
|
||||
"@emotion/react": "^11.11.3",
|
||||
|
||||
@@ -3,7 +3,7 @@ import { z } from 'zod';
|
||||
|
||||
import { LinkStorageDataType, LinkStorageVisibility } from '@prisma/client';
|
||||
|
||||
import { db } from '~/server/db';
|
||||
import { prismaDb } from '~/server/prisma/prismaDb';
|
||||
import { publicProcedure } from '~/server/api/trpc.server';
|
||||
|
||||
|
||||
@@ -103,7 +103,7 @@ export const storagePutProcedure =
|
||||
|
||||
const { ownerId, dataType, dataTitle, dataObject, expiresSeconds } = input;
|
||||
|
||||
const { id: objectId, ...rest } = await db.linkStorage.create({
|
||||
const { id: objectId, ...rest } = await prismaDb.linkStorage.create({
|
||||
select: {
|
||||
id: true,
|
||||
ownerId: true,
|
||||
@@ -146,7 +146,7 @@ export const storageGetProcedure =
|
||||
.query(async ({ input: { objectId, ownerId } }) => {
|
||||
|
||||
// read object
|
||||
const result = await db.linkStorage.findUnique({
|
||||
const result = await prismaDb.linkStorage.findUnique({
|
||||
select: {
|
||||
dataType: true,
|
||||
dataTitle: true,
|
||||
@@ -181,7 +181,7 @@ export const storageGetProcedure =
|
||||
// increment the read count
|
||||
// NOTE: fire-and-forget; we don't care about the result
|
||||
{
|
||||
db.linkStorage.update({
|
||||
prismaDb.linkStorage.update({
|
||||
select: {
|
||||
id: true,
|
||||
},
|
||||
@@ -217,7 +217,7 @@ export const storageMarkAsDeletedProcedure =
|
||||
.output(storageDeleteOutputSchema)
|
||||
.mutation(async ({ input: { objectId, ownerId, deletionKey } }) => {
|
||||
|
||||
const result = await db.linkStorage.updateMany({
|
||||
const result = await prismaDb.linkStorage.updateMany({
|
||||
where: {
|
||||
id: objectId,
|
||||
ownerId: ownerId || undefined,
|
||||
@@ -248,7 +248,7 @@ export const storageUpdateDeletionKeyProcedure =
|
||||
.output(storageUpdateDeletionKeyOutputSchema)
|
||||
.mutation(async ({ input: { objectId, ownerId, formerKey, newKey } }) => {
|
||||
|
||||
const result = await db.linkStorage.updateMany({
|
||||
const result = await prismaDb.linkStorage.updateMany({
|
||||
where: {
|
||||
id: objectId,
|
||||
ownerId: ownerId || undefined,
|
||||
|
||||
@@ -5,10 +5,10 @@ const globalForPrisma = globalThis as unknown as {
|
||||
prisma: PrismaClient | undefined;
|
||||
};
|
||||
|
||||
export const db =
|
||||
export const prismaDb =
|
||||
globalForPrisma.prisma ??
|
||||
new PrismaClient({
|
||||
log: process.env.NODE_ENV === 'development' ? ['query', 'error', 'warn'] : ['error'],
|
||||
});
|
||||
|
||||
if (process.env.NODE_ENV !== 'production') globalForPrisma.prisma = db;
|
||||
if (process.env.NODE_ENV !== 'production') globalForPrisma.prisma = prismaDb;
|
||||
Reference in New Issue
Block a user