-
-
Notifications
You must be signed in to change notification settings - Fork 118
Open
Description
Your Question
It's unclear how to:
- search for JSON fields in addition to other parameters in a query
- search for multiple JSON fields simultaneously
Given this:
type UserWithJSON struct {
gorm.Model
Name string
Attributes datatypes.JSON
}
DB.Create(&UserWithJSON{
Name: "json-1",
Attributes: datatypes.JSON([]byte(`{"name": "jinzhu", "age": 18, "tags": ["tag1", "tag2"], "orgs": {"orga": "orga"}}`)),
}
I should be able to query by Name AND multiple JSON fields, something along those lines:
res := dc.DB.WithContext(ctx).Where([]Row{{
Name: "jinzhu",
Attributes: *datatypes.JSONQuery("item_info").Equals(map[string]interface{"name":"jinzhu", "tags": []string{"tag1"}}),
}}).Find(&rows)
If it's possible, it's not clear to me how to. Thanks.
The document you expected this should be explained
README.
Expected answer
Clear example on how to filter by multiple cumulative fields.
Metadata
Metadata
Assignees
Labels
No labels