feat: added task repository
This commit is contained in:
@@ -0,0 +1,48 @@
|
|||||||
|
import { Injectable } from "@nestjs/common";
|
||||||
|
import { InjectRepository } from "@nestjs/typeorm";
|
||||||
|
import { Repository } from "typeorm";
|
||||||
|
import { TMTask } from "../entities/task.entity";
|
||||||
|
|
||||||
|
@Injectable()
|
||||||
|
export class TaskRepository {
|
||||||
|
constructor(
|
||||||
|
@InjectRepository(TMTask)
|
||||||
|
private readonly repository: Repository<TMTask>,
|
||||||
|
) {}
|
||||||
|
|
||||||
|
findAll() {
|
||||||
|
return this.repository.find({
|
||||||
|
relations: ["taskPhase", "remarks", "attachments", "checkListItems", "users"],
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
findByPhase(taskPhaseId: string) {
|
||||||
|
return this.repository.find({
|
||||||
|
where: { taskPhaseId },
|
||||||
|
relations: ["remarks", "attachments", "checkListItems", "users"],
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
findOneById(id: string) {
|
||||||
|
return this.repository.findOne({
|
||||||
|
where: { id },
|
||||||
|
relations: ["taskPhase", "remarks", "attachments", "checkListItems", "users"],
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
create(data: Partial<TMTask>) {
|
||||||
|
return this.repository.create(data);
|
||||||
|
}
|
||||||
|
|
||||||
|
save(task: TMTask) {
|
||||||
|
return this.repository.save(task);
|
||||||
|
}
|
||||||
|
|
||||||
|
update(id: string, data: Partial<TMTask>) {
|
||||||
|
return this.repository.update(id, data);
|
||||||
|
}
|
||||||
|
|
||||||
|
delete(id: string) {
|
||||||
|
return this.repository.delete(id);
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user