Passed
Pull Request — master (#165)
by Mathieu
03:20 queued 01:35
created

BillingRepository.save   A

Complexity

Conditions 1

Size

Total Lines 3
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 3
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
import { InjectRepository } from '@nestjs/typeorm';
2
import { Repository } from 'typeorm';
3
import { IBillingRepository } from 'src/Domain/Accounting/Repository/IBillingRepository';
4
import { Billing } from 'src/Domain/Accounting/Billing.entity';
5
6
export class BillingRepository implements IBillingRepository {
7
  constructor(
8
    @InjectRepository(Billing)
9
    private readonly repository: Repository<Billing>
10
  ) {}
11
12
  public save(billing: Billing): Promise<Billing> {
13
    return this.repository.save(billing);
14
  }
15
16
  public countByYear(year: number): Promise<number> {
17
    return this.repository
18
      .createQueryBuilder('billing')
19
      .select('billing.id')
20
      .where('extract(year FROM billing.createdAt) = :year', {year})
21
      .getCount();
22
  }
23
}
24