yarricharY
Convex Communityโ€ข3y agoโ€ข
12 replies
yarrichar

Database - Best way to model tags associated with an entity

I am storing a bunch of articles, each of which I want to store some tags against. I then want to be able to query for articles associated with one or more tags.

I've seen the join example under https://docs.convex.dev/database/reading-data#more-complex-queries but it doesn't seem like it will work well here.

For example if I have two tables:
- article
- article_tag

If I want to find articles that have tagA and tagB it seems like I would want to do something like:
fetch article_tag entries matching tagA
for each of those, X, fetch article_tag matching X.articleId and tagB
fetch all those results, Y, fetch articles matching Y.articleId
sort and return the first page

Hopefully I'm missing something ๐Ÿ™‚
Was this page helpful?