feat: add generated code: backend/src/equipment/equipment.service.ts
This commit is contained in:
41
backend/src/equipment/equipment.service.ts
Normal file
41
backend/src/equipment/equipment.service.ts
Normal file
@@ -0,0 +1,41 @@
|
|||||||
|
import { Injectable } from '@nestjs/common';
|
||||||
|
import { PrismaService } from '../prisma/prisma.service';
|
||||||
|
import { Equipment, Prisma } from '@prisma/client';
|
||||||
|
|
||||||
|
@Injectable()
|
||||||
|
export class EquipmentService {
|
||||||
|
constructor(private prisma: PrismaService) {}
|
||||||
|
|
||||||
|
async findAll(params: {
|
||||||
|
skip?: number;
|
||||||
|
take?: number;
|
||||||
|
where?: Prisma.EquipmentWhereInput;
|
||||||
|
orderBy?: Prisma.EquipmentOrderByWithRelationInput;
|
||||||
|
}): Promise<Equipment[]> {
|
||||||
|
const { skip, take, where, orderBy } = params;
|
||||||
|
return this.prisma.equipment.findMany({ skip, take, where, orderBy });
|
||||||
|
}
|
||||||
|
|
||||||
|
async count(where?: Prisma.EquipmentWhereInput): Promise<number> {
|
||||||
|
return this.prisma.equipment.count({ where });
|
||||||
|
}
|
||||||
|
|
||||||
|
async findOne(where: Prisma.EquipmentWhereUniqueInput): Promise<Equipment | null> {
|
||||||
|
return this.prisma.equipment.findUnique({ where });
|
||||||
|
}
|
||||||
|
|
||||||
|
async create(data: Prisma.EquipmentCreateInput): Promise<Equipment> {
|
||||||
|
return this.prisma.equipment.create({ data });
|
||||||
|
}
|
||||||
|
|
||||||
|
async update(params: {
|
||||||
|
where: Prisma.EquipmentWhereUniqueInput;
|
||||||
|
data: Prisma.EquipmentUpdateInput;
|
||||||
|
}): Promise<Equipment> {
|
||||||
|
return this.prisma.equipment.update(params);
|
||||||
|
}
|
||||||
|
|
||||||
|
async remove(where: Prisma.EquipmentWhereUniqueInput): Promise<Equipment> {
|
||||||
|
return this.prisma.equipment.delete({ where });
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user