Hstore type and predicates for Ent.

This package defines the Postgres hstore type
to be used with ent and a few predicates.

Using the type:

func (User) Fields() []ent.Field {
	return []ent.Field{
		field.Other("attributes", enthstore.Hstore{}).
			Default(func() enthstore.Hstore {
				return enthstore.Hstore{}

Using the predicates:

users, err := client.User.Query().Where(func(selector *sql.Selector) {
    selector.Where(enthstore.HasKey(user.FieldAttributes, "a"))

List of predicates:

  • 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:

    model: github.com/crossworth/enthstore.Hstore


View Github