Here is the two model with manytomany relationship. Right now I want to query the topic by category name. I know I could achieve this by raw sql like select * from topic where id IN (SELECT topic_id from topic_categories where category_id IN (select id from category where name ILIKE '%tech%'));
The question is, how to do this with gorm in a higher performance and more readable way.
type Category struct {
Name string
}
type Topic struct {
Name string
Categories []*Category `gorm:"manytomany;topic_categories"`
}