Total Complexity | 3 |
Complexity/F | 1 |
Lines of Code | 28 |
Function Count | 3 |
Duplicated Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | import {InjectRepository} from '@nestjs/typeorm'; |
||
2 | import {Repository} from 'typeorm'; |
||
3 | import {IFileRepository} from 'src/Domain/File/Repository/IFileRepository'; |
||
4 | import {File} from 'src/Domain/File/File.entity'; |
||
5 | |||
6 | export class FileRepository implements IFileRepository { |
||
7 | constructor( |
||
8 | @InjectRepository(File) |
||
9 | private readonly repository: Repository<File> |
||
10 | ) {} |
||
11 | |||
12 | public save(file: File): Promise<File> { |
||
13 | return this.repository.save(file); |
||
14 | } |
||
15 | |||
16 | public remove(file: File): void { |
||
17 | this.repository.delete(file.getId()); |
||
18 | } |
||
19 | |||
20 | public findOneById(id: string): Promise<File | undefined> { |
||
21 | return this.repository |
||
22 | .createQueryBuilder('file') |
||
23 | .select(['file.id', 'file.name', 'file.mimeType', 'file.uploadedAt']) |
||
24 | .where('file.id = :id', {id}) |
||
25 | .getOne(); |
||
26 | } |
||
27 | } |
||
28 |