import { prisma, type UpdateSuspensionInput, type UpdateUserInput, type User } from "@minikura/db"; import { UserRole } from "../../../domain/entities/enums"; import type { UserRepository } from "../../../domain/repositories/user.repository"; export class PrismaUserRepository implements UserRepository { async findById(id: string): Promise { return await prisma.user.findUnique({ where: { id }, }); } async findByEmail(email: string): Promise { return await prisma.user.findUnique({ where: { email }, }); } async findAll(): Promise { return await prisma.user.findMany({ orderBy: { createdAt: "desc" }, }); } async update(id: string, input: UpdateUserInput): Promise { return await prisma.user.update({ where: { id }, data: input, }); } async updateSuspension(id: string, input: UpdateSuspensionInput): Promise { return await prisma.user.update({ where: { id }, data: input, }); } async delete(id: string): Promise { await prisma.user.delete({ where: { id }, }); } async count(): Promise { return await prisma.user.count(); } }