Building a REST API with NestJS and Prisma: Authentication
https://www.prisma.io/blog/nestjs-prisma-rest-api-7D056s1BmOL0
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
29 lines
774 B
29 lines
774 B
import { Injectable } from '@nestjs/common';
|
|
import { CreateUserDto } from './dto/create-user.dto';
|
|
import { UpdateUserDto } from './dto/update-user.dto';
|
|
import { PrismaService } from 'src/prisma/prisma.service';
|
|
|
|
@Injectable()
|
|
export class UsersService {
|
|
constructor(private prisma: PrismaService) { }
|
|
|
|
create(createUserDto: CreateUserDto) {
|
|
return this.prisma.user.create({ data: createUserDto })
|
|
}
|
|
|
|
findAll() {
|
|
return this.prisma.user.findMany()
|
|
}
|
|
|
|
findOne(id: number) {
|
|
return this.prisma.user.findUnique({ where: { id } })
|
|
}
|
|
|
|
update(id: number, updateUserDto: UpdateUserDto) {
|
|
return this.prisma.user.update({ where: { id }, data: updateUserDto })
|
|
}
|
|
|
|
remove(id: number) {
|
|
return this.prisma.user.delete({ where: { id } })
|
|
}
|
|
}
|