nest-project/src/users/users.service.ts

20 lines
552 B
TypeScript
Raw Normal View History

2023-02-16 10:40:03 +08:00
import { Injectable, NotFoundException } from '@nestjs/common'
2023-02-15 20:32:14 +08:00
import { PrismaService } from 'nestjs-prisma'
2023-02-16 10:40:03 +08:00
import { Prisma } from '@prisma/client'
2023-02-17 14:21:08 +08:00
import { UserEntity } from './entities/user.entity'
2023-02-15 20:32:14 +08:00
@Injectable()
export class UsersService {
constructor(private prismaService: PrismaService) {}
2023-02-16 10:40:03 +08:00
2023-02-17 14:21:08 +08:00
async findUser(where: Prisma.UserWhereUniqueInput): Promise<UserEntity> {
const user = await this.prismaService.user.findUnique({
2023-02-16 10:40:03 +08:00
where,
})
if (!user) {
throw new NotFoundException(`No user found`)
}
return user
}
2023-02-15 20:32:14 +08:00
}