Skip to content

[QUESTION] Has-many filtering queries #666

@kubakl

Description

@kubakl

I need to query for entities that have a has-many relation with another table. Example:

type Recipe struct {
    ID int64
    Name string
    Categories []*RecipeCategory `bun:"rel:has-many,join:id=recipe_id"`
}

type Category struct {
    ID int64
    Name string
}

type RecipeCategory struct {
    ID int64
    CategoryID int64
    RecipeID int64
}

Let's say I want to query for a recipe where category_id is equal to 1 or 2. How I can do that?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions