All files / src/modules/developers developers.service.ts

42.85% Statements 6/14
60% Branches 3/5
16.66% Functions 1/6
36.36% Lines 4/11

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 2811x 11x     11x 11x                                            
import { Injectable, NotFoundException } from '@nestjs/common';
import { PrismaService } from '@app/modules/prisma/prisma.service';
 
@Injectable()
export class DevelopersService {
  constructor(private readonly prisma: PrismaService) {}
 
  listDevelopers() {
    return this.prisma.client.developerCompany.findMany({ orderBy: { name: 'asc' } });
  }
 
  async getDeveloper(id: number) {
    const dev = await this.prisma.client.developerCompany.findUnique({ where: { id } });
    Iif (!dev) throw new NotFoundException('Developer not found');
    return dev;
  }
 
  getDeveloperProjects(id: number) {
    return this.prisma.client.project.findMany({ where: { developerCompanyId: id }, include: { address: true } });
  }
 
  listProjects() { return this.prisma.client.project.findMany({ include: { address: true, developerCompany: true } } as any); }
 
  listUnits(projectId: number) { return this.prisma.client.unit.findMany({ where: { projectId } }); }
}