39 lines
1.1 KiB
TypeScript
39 lines
1.1 KiB
TypeScript
import Database from "@Common/databases/database";
|
|
import { OfficeFolderHasStakeholders } from "@prisma/client";
|
|
import BaseRepository from "@Repositories/BaseRepository";
|
|
import { Service } from "typedi";
|
|
|
|
@Service()
|
|
export default class OfficeFoldersHasStakeholderRepository extends BaseRepository {
|
|
constructor(private database: Database) {
|
|
super();
|
|
}
|
|
protected get model() {
|
|
return this.database.getClient().officeFolderHasStakeholders;
|
|
}
|
|
protected get instanceDb() {
|
|
return this.database.getClient();
|
|
}
|
|
|
|
/**
|
|
* @description : Find many relations
|
|
*/
|
|
public async findMany(query: any): Promise<OfficeFolderHasStakeholders[]> {
|
|
query.take = Math.min(query.take || this.defaultFetchRows, this.maxFetchRows);
|
|
return this.model.findMany(query);
|
|
}
|
|
|
|
/**
|
|
* @description : Find a unique relation between an office folder and stakeholders
|
|
*/
|
|
public async findOneByUid(uid: string): Promise<OfficeFolderHasStakeholders | null> {
|
|
const officeFolderHasStakeholdersEntity = await this.model.findUnique({
|
|
where: {
|
|
uid: uid,
|
|
},
|
|
});
|
|
|
|
return officeFolderHasStakeholdersEntity;
|
|
}
|
|
}
|