mirror of
https://github.com/Tria-plc/edr-platform.git
synced 2026-08-28 10:10:57 +00:00
37 lines
973 B
TypeScript
37 lines
973 B
TypeScript
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 } });
|
|
}
|
|
|
|
async deleteByCode(
|
|
resourceId: string,
|
|
resource: string,
|
|
code: string,
|
|
): Promise<void> {
|
|
await this.repository.delete({ resourceId, resource, code });
|
|
}
|
|
}
|