29 lines
759 B
TypeScript
29 lines
759 B
TypeScript
import { Injectable } from '@nestjs/common';
|
|
import { PrismaService } from '@/src/prisma.service';
|
|
import { users } from '@prisma/client';
|
|
|
|
@Injectable()
|
|
export class UsersService {
|
|
constructor(private prisma: PrismaService) {}
|
|
|
|
async findAll(): Promise<users[]> {
|
|
return this.prisma.users.findMany();
|
|
}
|
|
|
|
async findOne(id: number): Promise<users | null> {
|
|
return this.prisma.users.findUnique({ where: { id } });
|
|
}
|
|
|
|
async create(data: any): Promise<users> {
|
|
return this.prisma.users.create({ data });
|
|
}
|
|
|
|
async update(id: number, data: any): Promise<users> {
|
|
return this.prisma.users.update({ where: { id }, data });
|
|
}
|
|
|
|
async remove(id: number): Promise<users> {
|
|
return this.prisma.users.delete({ where: { id } });
|
|
}
|
|
}
|