Files
setrip/server/repositories/review.repo.ts
T
2026-04-20 00:25:05 +07:00

27 lines
561 B
TypeScript

import { prisma } from "@/lib/prisma";
export const reviewRepo = {
async upsert(data: {
tripId: string;
userId: string;
rating: number;
comment: string | null;
}) {
return prisma.tripReview.upsert({
where: {
tripId_userId: { tripId: data.tripId, userId: data.userId },
},
create: {
tripId: data.tripId,
userId: data.userId,
rating: data.rating,
comment: data.comment,
},
update: {
rating: data.rating,
comment: data.comment,
},
});
},
};