Documentation
¶
Index ¶
- func GetOrdering(order sortx.Order) []sql.OrderTermOption
- func JSONBIn(field string, key string, values []string) func(*sql.Selector)
- func JSONBKeyExistsInObject(field string, member string, expectedKey string) func(*sql.Selector)
- func JSONStringValueScanner[T any]() field.ValueScannerFunc[T, *sql.NullString]
- func TransactingRepo[R, T any](ctx context.Context, repo interface{ ... }, ...) (R, error)
- func TransactingRepoWithNoValue[T any](ctx context.Context, repo interface{ ... }, ...) error
- type CadencedMixin
- type CustomerAddressMixin
- type IDMixin
- type KeyMixin
- type MetadataAnnotationsMixin
- type NamespaceMixin
- type RawEntConfig
- type ResourceMixin
- type TimeMixin
- type Transactable
- type TxCreator
- type TxDriver
- type TxHijacker
- type TxUser
- type ULID
- type UniqueResourceMixin
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetOrdering ¶
func GetOrdering(order sortx.Order) []sql.OrderTermOption
func JSONBIn ¶
JSONBIn returns a function that filters the given JSONB field by the given key and value Caveats: - PostgreSQL only - The field must be a JSONB field - The value must be a string (no support for other types, ->> converts all values to string) - This might not work if there's a join involved in the query, so add unit tests
func JSONBKeyExistsInObject ¶
JSONBKeyExistsInObject returns a function that filters the given JSONB field by mandating that a key exists in a specifc object.
Example: given the field value of
{"failed": false, "immutable": false, "availableActions": {"delete": {"resultingState": "deleted"}, "advance": {"resultingState": "draft.waiting_auto_approval"}}}
JSONBKeyExistsInObject("status_details_cache", "availableActions", "advance")
filters for such records that have the advance as an available action.
Resulting condition:
status_details_cache -> 'availableActions' ? 'advance'
func JSONStringValueScanner ¶
func JSONStringValueScanner[T any]() field.ValueScannerFunc[T, *sql.NullString]
func TransactingRepo ¶
func TransactingRepo[R, T any]( ctx context.Context, repo interface { TxUser[T] TxCreator }, cb func(ctx context.Context, rep T) (R, error), ) (R, error)
TransactingRepo is a helper that can be used inside repository methods. It uses any preexisting transaction in the context or starts and executes a new one.
Types ¶
type CadencedMixin ¶
func (CadencedMixin) Fields ¶
func (CadencedMixin) Fields() []ent.Field
type CustomerAddressMixin ¶
CustomerAddressMixin adds address fields to a customer, used by billing to snapshot addresses for invoices
func (CustomerAddressMixin) Fields ¶
func (c CustomerAddressMixin) Fields() []ent.Field
type MetadataAnnotationsMixin ¶
MetadataAnnotationsMixin adds metadata to the schema
func (MetadataAnnotationsMixin) Fields ¶
func (MetadataAnnotationsMixin) Fields() []ent.Field
Fields of the IDMixin.
type NamespaceMixin ¶
NamespaceMixin can be used for namespaced entities
func (NamespaceMixin) Indexes ¶
func (NamespaceMixin) Indexes() []ent.Index
type RawEntConfig ¶
type ResourceMixin ¶
ResourceMixin adds common fields
func (ResourceMixin) Fields ¶
func (ResourceMixin) Fields() []ent.Field
func (ResourceMixin) Indexes ¶
func (ResourceMixin) Indexes() []ent.Index
type Transactable ¶
type TxDriver ¶
type TxDriver struct {
// contains filtered or unexported fields
}
func GetDriverFromContext ¶
Only use for direct interacton with the Ent driver implementation
func NewTxDriver ¶
func NewTxDriver(driver Transactable, cfg *RawEntConfig) *TxDriver
func (*TxDriver) GetConfig ¶
func (t *TxDriver) GetConfig() *RawEntConfig
type TxHijacker ¶
type TxHijacker interface {
HijackTx(ctx context.Context, opts *sql.TxOptions) (context.Context, *RawEntConfig, Transactable, error)
}
type TxUser ¶
type TxUser[T any] interface { // Creates a new instance of the adapter using the provided transaction. // Example: // // type dbAdapter struct { // db *db.Client // } // // func (d *dbAdapter) WithTx(ctx context.Context, tx *entutils.TxDriver) SomeDB[db1.Example1] { // // NewTxClientFromRawConfig gets generated when using expose.tpl // txClient := db.NewTxClientFromRawConfig(ctx, *tx.GetConfig()) // res := &db1Adapter{db: txClient.Client()} // return res // } WithTx(ctx context.Context, tx *TxDriver) T }
Able to use an existing transaction
type ULID ¶
type ULID struct {
ulid.ULID
}
ULID implements a valuer (and Scanner) that can serialize string ULIDs into postgres instead of the binary representation, as postgres interprets those as UTF-8 strings
func (*ULID) ULIDPointer ¶
func (v *ULID) ULIDPointer() *ulid.ULID
type UniqueResourceMixin ¶
UniqueResourceMixin adds common fields
func (UniqueResourceMixin) Fields ¶
func (UniqueResourceMixin) Fields() []ent.Field
func (UniqueResourceMixin) Indexes ¶
func (UniqueResourceMixin) Indexes() []ent.Index