installation.ts 603 B

123456789101112131415161718192021
  1. import { EntityRepository, Repository } from 'typeorm';
  2. import { Installation } from '~/entities/installation';
  3. @EntityRepository(Installation)
  4. export class InstallationRepository extends Repository<Installation> {
  5. findByID(id: string): Promise<Installation | undefined> {
  6. return this.findOne(id);
  7. }
  8. async findByTeamIdOrEnterpriseId(
  9. teamIdOrEnterpriseId: string,
  10. ): Promise<Installation | undefined> {
  11. return this.findOne({
  12. where: [
  13. { teamId: teamIdOrEnterpriseId },
  14. { enterpriseId: teamIdOrEnterpriseId, isEnterpriseInstall: true },
  15. ],
  16. });
  17. }
  18. }