First unchecked draft for tags
This commit is contained in:
parent
f936e84168
commit
70b132dc6f
51 changed files with 494 additions and 69 deletions
24
src/repositories/TagRepository.ts
Normal file
24
src/repositories/TagRepository.ts
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
import { AbstractRepository } from "./AbstractRepository.js";
|
||||
import { TagEntity } from "../entities/TagEntity.js";
|
||||
|
||||
/**
|
||||
* Repository for TagEntity.
|
||||
* The AbstractRepository already provides findById, findAll, create, update,
|
||||
* and delete. Tag-specific queries can be added here as needed.
|
||||
*/
|
||||
export class TagRepository extends AbstractRepository<TagEntity> {
|
||||
constructor() {
|
||||
super(TagEntity);
|
||||
}
|
||||
|
||||
/**
|
||||
* Looks up a tag by its description (case-insensitive).
|
||||
* Useful for detecting duplicates before creating a new tag.
|
||||
*/
|
||||
async findByDescription(description: string): Promise<TagEntity | null> {
|
||||
return this.repo
|
||||
.createQueryBuilder("tag")
|
||||
.where("LOWER(tag.description) = LOWER(:description)", { description })
|
||||
.getOne();
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue