auth, trips and join trips
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
import { prisma } from "@/lib/prisma";
|
||||
|
||||
export const participantRepo = {
|
||||
async findByTripAndUser(tripId: string, userId: string) {
|
||||
return prisma.tripParticipant.findUnique({
|
||||
where: { tripId_userId: { tripId, userId } },
|
||||
});
|
||||
},
|
||||
|
||||
async create(tripId: string, userId: string) {
|
||||
return prisma.tripParticipant.create({
|
||||
data: { tripId, userId, status: "CONFIRMED" },
|
||||
});
|
||||
},
|
||||
|
||||
async countByTrip(tripId: string) {
|
||||
return prisma.tripParticipant.count({
|
||||
where: { tripId, status: { not: "CANCELLED" } },
|
||||
});
|
||||
},
|
||||
|
||||
async cancel(tripId: string, userId: string) {
|
||||
return prisma.tripParticipant.update({
|
||||
where: { tripId_userId: { tripId, userId } },
|
||||
data: { status: "CANCELLED" },
|
||||
});
|
||||
},
|
||||
};
|
||||
Reference in New Issue
Block a user