Total Complexity | 3 |
Total Lines | 20 |
Duplicated Lines | 0 % |
Changes | 0 |
1 | import {InjectRepository} from '@nestjs/typeorm'; |
||
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(); |
||
28 |