I have tags and articles entities that linked by many to many. How can I find tags if I know article id?
@Entity("articles")
class ArticleEntity {
@ManyToMany(() => TagEntity, tag => tag.articles)
@JoinTable()
tags: TagEntity[];
}
@Entity("tags")
class TagEntity {
@ManyToMany(() => ArticleEntity, article => article.tags)
articles: ArticleEntity[];
}
const articleId = 1;
this.tagRepo.find({ where: { articles: { id: articleId } } }); // ??
FindOptions
QueryBuilder
you can join them