import { PrismaClient , FindManyUserArgs } from "@prisma/client" ; import { PaginationArgs , offsetToPrismaPagination } from "./utils" ; export class UserService { constructor ( protected prisma ) { } async findOne ( params ) { const user = await this . prisma . user . findOne ( { where : { id : params . id } } ) ; if ( ! user ) { throw new Error ( "could not find user with id: " + params . id ) ; } return user ; } findMany ( params ) { return this . prisma . user . findMany ( { ... offsetToPrismaPagination ( params ) , orderBy : params . orderBy ?? undefined , } ) ; } async count ( ) { return this . prisma . post . count ( ) ; } }