mirror of
https://github.com/Tria-plc/edr-platform.git
synced 2026-09-08 22:58:17 +00:00
implement file module and add files relation to booking entity and populate on fetch
This commit is contained in:
28
apps/edr-freight-api/src/modules/files/files.repository.ts
Normal file
28
apps/edr-freight-api/src/modules/files/files.repository.ts
Normal file
@@ -0,0 +1,28 @@
|
||||
import { BaseRepository } from "@edr/api-common";
|
||||
import { Injectable } from "@nestjs/common";
|
||||
import { InjectRepository } from "@nestjs/typeorm";
|
||||
import { Repository } from "typeorm";
|
||||
|
||||
import { FileRecord } from "./entities/file.entity";
|
||||
|
||||
@Injectable()
|
||||
export class FilesRepository extends BaseRepository<FileRecord> {
|
||||
constructor(
|
||||
@InjectRepository(FileRecord)
|
||||
repository: Repository<FileRecord>,
|
||||
) {
|
||||
super(repository);
|
||||
}
|
||||
|
||||
findByResource(resourceId: string, resource: string): Promise<FileRecord[]> {
|
||||
return this.repository.find({ where: { resourceId, resource } });
|
||||
}
|
||||
|
||||
findByCode(
|
||||
resourceId: string,
|
||||
resource: string,
|
||||
code: string,
|
||||
): Promise<FileRecord | null> {
|
||||
return this.repository.findOne({ where: { resourceId, resource, code } });
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user