feat: added remark repository
This commit is contained in:
@@ -0,0 +1,47 @@
|
||||
import { Injectable } from "@nestjs/common";
|
||||
import { InjectRepository } from "@nestjs/typeorm";
|
||||
import { Repository } from "typeorm";
|
||||
import { TMRemark } from "../entities/remark.entity";
|
||||
|
||||
@Injectable()
|
||||
export class RemarkRepository {
|
||||
constructor(
|
||||
@InjectRepository(TMRemark)
|
||||
private readonly repository: Repository<TMRemark>,
|
||||
) {}
|
||||
|
||||
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<TMRemark>) {
|
||||
return this.repository.create(data);
|
||||
}
|
||||
|
||||
save(remark: TMRemark) {
|
||||
return this.repository.save(remark);
|
||||
}
|
||||
|
||||
update(id: string, data: Partial<TMRemark>) {
|
||||
return this.repository.update(id, data);
|
||||
}
|
||||
|
||||
delete(id: string) {
|
||||
return this.repository.delete(id);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user