diff --git a/src/modules/task-manager/repositories/attachment.repository.ts b/src/modules/task-manager/repositories/attachment.repository.ts new file mode 100644 index 0000000..9fd3f26 --- /dev/null +++ b/src/modules/task-manager/repositories/attachment.repository.ts @@ -0,0 +1,47 @@ +import { Injectable } from '@nestjs/common'; +import { InjectRepository } from '@nestjs/typeorm'; +import { Repository } from 'typeorm'; +import { TMAttachment } from '../entities/attachment.entity'; + +@Injectable() +export class AttachmentRepository { + constructor( + @InjectRepository(TMAttachment) + private readonly repository: Repository, + ) {} + + findAll() { + return this.repository.find({ + relations: ['task'], + }); + } + + findByTask(taskId: string) { + return this.repository.find({ + where: { taskId }, + }); + } + + findOneById(id: string) { + return this.repository.findOne({ + where: { id }, + relations: ['task'], + }); + } + + create(data: Partial) { + return this.repository.create(data); + } + + save(attachment: TMAttachment) { + return this.repository.save(attachment); + } + + update(id: string, data: Partial) { + return this.repository.update(id, data); + } + + delete(id: string) { + return this.repository.delete(id); + } +} \ No newline at end of file