47 lines
1.0 KiB
TypeScript
47 lines
1.0 KiB
TypeScript
import { Injectable } from '@nestjs/common';
|
|
import { InjectRepository } from '@nestjs/typeorm';
|
|
import { Repository } from 'typeorm';
|
|
import { TMCheckListItem } from '../entities/check-list-item.entity';
|
|
|
|
@Injectable()
|
|
export class CheckListItemRepository {
|
|
constructor(
|
|
@InjectRepository(TMCheckListItem)
|
|
private readonly repository: Repository<TMCheckListItem>,
|
|
) {}
|
|
|
|
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<TMCheckListItem>) {
|
|
return this.repository.create(data);
|
|
}
|
|
|
|
save(checkListItem: TMCheckListItem) {
|
|
return this.repository.save(checkListItem);
|
|
}
|
|
|
|
update(id: string, data: Partial<TMCheckListItem>) {
|
|
return this.repository.update(id, data);
|
|
}
|
|
|
|
delete(id: string) {
|
|
return this.repository.delete(id);
|
|
}
|
|
} |