Passed
Pull Request — master (#72)
by Mathieu
01:28
created

server/src/Infrastructure/Customer/Repository/AddressRepository.ts   A

Complexity

Total Complexity 2
Complexity/F 1

Size

Lines of Code 25
Function Count 2

Duplication

Duplicated Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
wmc 2
eloc 20
mnd 0
bc 0
fnc 2
dl 0
loc 25
rs 10
bpm 0
cpm 1
noi 0
c 0
b 0
f 0

2 Functions

Rating   Name   Duplication   Size   Complexity  
A AddressRepository.save 0 3 1
A AddressRepository.findOneById 0 5 1
1
import {Injectable} from '@nestjs/common';
2
import {InjectRepository} from '@nestjs/typeorm';
3
import {Repository} from 'typeorm';
4
import {IAddressRepository} from 'src/Domain/Customer/Repository/IAddressRepository';
5
import {Address} from 'src/Domain/Customer/Address.entity';
6
7
@Injectable()
8
export class AddressRepository implements IAddressRepository {
9
  constructor(
10
    @InjectRepository(Address)
11
    private readonly repository: Repository<Address>
12
  ) {}
13
14
  public save(address: Address): Promise<Address> {
15
    return this.repository.save(address);
16
  }
17
18
  public findOneById(id: string): Promise<Address | undefined> {
19
    return this.repository
20
      .createQueryBuilder('customer')
21
      .where('customer.id = :id', {id})
22
      .getOne();
23
  }
24
}
25