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

AddressRepository.save   A

Complexity

Conditions 1

Size

Total Lines 3
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 3
dl 0
loc 3
rs 10
c 0
b 0
f 0
cc 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