Replies: 1 comment
-
var items []Recipe
err := service.GetDB().NewSelect().
Model(&items).
Relation("Categories", func(q *bun.SelectQuery) *bun.SelectQuery {
return q.Where("category_id IN (?)", bun.In([]int64{1, 2}))
}).
Scan(context.Background())
if err != nil {
panic(err)
}
fmt.Printf("%v\n", items) |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I need to query for entities that have a
has-many
relation with another table. Example:Let's say I want to query for a recipe where category_id is equal to 1 or 2. How I can do that?
Beta Was this translation helpful? Give feedback.
All reactions