import { Injectable } from '@nestjs/common'; import { InjectRepository } from '@nestjs/typeorm'; import { Repository } from 'typeorm'; import { EntityTable } from '../entity/entity-table.entity'; @Injectable() export class EntityTableRepository { constructor( @InjectRepository(EntityTable) private entityTableRepository: Repository, ) {} async findByEntityTypeAndListType(entityType: string, listType: string) { const temp = await this.entityTableRepository.findOne({ where: { mapped_entity_type: entityType, list_type: listType }, }); return temp; } async findByMappedEntityType( mappedEntityType: string, enterprise_id: number, ) { return await this.entityTableRepository.findOne({ where: { mapped_entity_type: mappedEntityType, display_type: 'LIST', enterprise_id: enterprise_id, }, }); } async findByEntityTypeAndListTypeAndDisplayType( entityType: string, listType: string, displayType: string, enterprise_id: number, ) { const whereCondition: any = { mapped_entity_type: entityType, list_type: listType, display_type: displayType, enterprise_id: enterprise_id, }; return await this.entityTableRepository.findOne({ where: { ...whereCondition, }, }); } }