Files
twenty/server/src/entities/company/company.repository.ts
Charles Bochet 0f9c6dede7 Clean server post refactor to remove Hasura (#156)
* Clean BE post refactor to remove Hasura

* Add server CI
2023-05-29 22:42:24 +02:00

26 lines
801 B
TypeScript

import { Injectable } from '@nestjs/common';
import { Company, Prisma } from '@prisma/client';
import { PrismaService } from 'src/database/prisma.service';
@Injectable()
export class CompanyRepository {
constructor(private prisma: PrismaService) {}
async findMany(params: {
skip?: number;
take?: number;
cursor?: Prisma.CompanyWhereUniqueInput;
where?: Prisma.CompanyWhereInput;
orderBy?: Prisma.CompanyOrderByWithRelationInput;
}): Promise<Company[]> {
const { skip, take, cursor, where, orderBy } = params;
return this.prisma.company.findMany({ skip, take, cursor, where, orderBy });
}
async findOne(id: string | null) {
if (id === null) return null;
const company = await this.prisma.company.findUnique({ where: { id } });
return company;
}
}