This package defines the Postgres hstore
type
to be used with ent
and a few predicates.
func (User) Fields() []ent.Field {
return []ent.Field{
field.Other("attributes", enthstore.Hstore{}).
SchemaType(enthstore.Hstore{}.SchemaType()).
Default(func() enthstore.Hstore {
return enthstore.Hstore{}
}),
}
}
users, err := client.User.Query().Where(func(selector *sql.Selector) {
selector.Where(enthstore.HasKey(user.FieldAttributes, "a"))
}).All(context.Background)
- HasKey
- HasAllKeys
- ValueIsNull
- ValueEQ
- ValueNEQ
- ValueGT
- ValueGTE
- ValueLT
- ValueLTE
- ValueContains
- ValueHasPrefix
- ValueHasSuffix
Using with GQLGen:
Define a custom scalar:
scalar Hstore
And declare the type mapping on gqlgen.yml
:
models:
Hstore:
model: github.com/crossworth/enthstore.Hstore