mirror of
https://github.com/Tria-plc/edr-platform.git
synced 2026-08-29 21:08:12 +00:00
31 lines
941 B
TypeScript
31 lines
941 B
TypeScript
import { Injectable } from '@nestjs/common';
|
|
import { InjectRepository } from '@nestjs/typeorm';
|
|
import { Repository } from 'typeorm';
|
|
import { BaseRepository } from '@edr/api-common';
|
|
import { ExternalProfile } from './entities/external-profile.entity';
|
|
|
|
@Injectable()
|
|
export class ExternalProfileRepository extends BaseRepository<ExternalProfile> {
|
|
constructor(
|
|
@InjectRepository(ExternalProfile)
|
|
repo: Repository<ExternalProfile>,
|
|
) {
|
|
super(repo);
|
|
}
|
|
|
|
async findByUserId(userId: string): Promise<ExternalProfile | null> {
|
|
return this.repository.findOne({
|
|
where: { userId } as any,
|
|
relations: ['company'],
|
|
});
|
|
}
|
|
|
|
async findByCompanyId(companyId: string): Promise<ExternalProfile[]> {
|
|
return this.repository.find({ where: { companyId } as any });
|
|
}
|
|
|
|
async findByEmail(email: string): Promise<ExternalProfile | null> {
|
|
return this.repository.findOne({ where: { email } as any });
|
|
}
|
|
}
|