28 lines
616 B
TypeScript
28 lines
616 B
TypeScript
|
|
import { Injectable } from '@nestjs/common'
|
||
|
|
import { PrismaService } from '../prisma/prisma.service'
|
||
|
|
|
||
|
|
@Injectable()
|
||
|
|
export class CustomersService {
|
||
|
|
constructor(private prisma: PrismaService) {}
|
||
|
|
|
||
|
|
create(data: any) {
|
||
|
|
return this.prisma.customer.create({ data })
|
||
|
|
}
|
||
|
|
|
||
|
|
findAll() {
|
||
|
|
return this.prisma.customer.findMany()
|
||
|
|
}
|
||
|
|
|
||
|
|
findOne(id: number) {
|
||
|
|
return this.prisma.customer.findUnique({ where: { id } })
|
||
|
|
}
|
||
|
|
|
||
|
|
update(id: number, data: any) {
|
||
|
|
return this.prisma.customer.update({ where: { id }, data })
|
||
|
|
}
|
||
|
|
|
||
|
|
remove(id: number) {
|
||
|
|
return this.prisma.customer.delete({ where: { id } })
|
||
|
|
}
|
||
|
|
}
|