Documentation
¶
Index ¶
- Variables
- func GetOrdering(order sortx.Order) []sql.OrderTermOption
- func InIDOrder[T InIDOrderAccessor](namespace string, targetOrderIDs []string, results []T) ([]T, error)
- 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 MapPaged[I, O any](paged pagination.Result[I], mapper func(I) O) pagination.Result[O]
- func MapPagedWithErr[I, O any](paged pagination.Result[I], mapper func(I) (O, error)) (pagination.Result[O], error)
- func MapTimeMixinFromDB[T TimeMixinGetter](dbEntity T) models.ManagedModel
- func TransactingRepo[R, T any](ctx context.Context, repo interface{ ... }, ...) (R, error)
- func TransactingRepoWithNoValue[T any](ctx context.Context, repo interface{ ... }, ...) error
- type AnnotationsMixin
- type AnnotationsMixinGetter
- type AnnotationsMixinSetter
- type CadencedMixin
- type CustomerAddressMixin
- type IDMixin
- type IDMixinCreator
- type IDMixinGetter
- type InIDOrderAccessor
- type KeyMixin
- type MetadataMixin
- type MixinWithAdditionalMixins
- type NamespaceMixin
- type NamespaceMixinCreator
- type NamespaceMixinGetter
- type RawEntConfig
- type RecursiveMixin
- func (r RecursiveMixin[T]) Annotations() []schema.Annotation
- func (r RecursiveMixin[T]) Edges() []ent.Edge
- func (r RecursiveMixin[T]) Fields() []ent.Field
- func (r RecursiveMixin[T]) Hooks() []ent.Hook
- func (r RecursiveMixin[T]) Indexes() []ent.Index
- func (r RecursiveMixin[T]) Interceptors() []ent.Interceptor
- func (r RecursiveMixin[T]) Policy() ent.Policy
- type ResourceMixin
- type TimeMixin
- type TimeMixinCreator
- type TimeMixinGetter
- type TimeMixinUpdater
- type Transactable
- type TxCreator
- type TxDriver
- type TxHijacker
- type TxUser
- type ULID
- type UniqueResourceMixin
Constants ¶
This section is empty.
Variables ¶
Functions ¶
func GetOrdering ¶
func GetOrdering(order sortx.Order) []sql.OrderTermOption
func InIDOrder ¶
func InIDOrder[T InIDOrderAccessor](namespace string, targetOrderIDs []string, results []T) ([]T, error)
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 MapPaged ¶
func MapPaged[I, O any](paged pagination.Result[I], mapper func(I) O) pagination.Result[O]
func MapPagedWithErr ¶
func MapPagedWithErr[I, O any](paged pagination.Result[I], mapper func(I) (O, error)) (pagination.Result[O], error)
func MapTimeMixinFromDB ¶
func MapTimeMixinFromDB[T TimeMixinGetter](dbEntity T) models.ManagedModel
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 if exists.
Types ¶
type AnnotationsMixin ¶
AnnotationsMixin adds annotations to the schema
func (AnnotationsMixin) Fields ¶
func (AnnotationsMixin) Fields() []ent.Field
Fields of the IDMixin.
func (AnnotationsMixin) Indexes ¶
func (AnnotationsMixin) Indexes() []ent.Index
type AnnotationsMixinGetter ¶
type AnnotationsMixinGetter interface {
GetAnnotations() models.Annotations
}
type AnnotationsMixinSetter ¶
type AnnotationsMixinSetter[T any] interface { SetAnnotations(annotations models.Annotations) T }
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 IDMixinCreator ¶
type IDMixinGetter ¶
type IDMixinGetter interface {
GetID() string
}
type InIDOrderAccessor ¶
type InIDOrderAccessor interface {
IDMixinGetter
NamespaceMixinGetter
}
type MetadataMixin ¶
MetadataMixin adds metadata to the schema
type NamespaceMixin ¶
NamespaceMixin can be used for namespaced entities
func (NamespaceMixin) Indexes ¶
func (NamespaceMixin) Indexes() []ent.Index
type NamespaceMixinCreator ¶
type NamespaceMixinGetter ¶
type NamespaceMixinGetter interface {
GetNamespace() string
}
type RawEntConfig ¶
type RecursiveMixin ¶
type RecursiveMixin[T MixinWithAdditionalMixins] struct{}
func (RecursiveMixin[T]) Annotations ¶
func (r RecursiveMixin[T]) Annotations() []schema.Annotation
func (RecursiveMixin[T]) Edges ¶
func (r RecursiveMixin[T]) Edges() []ent.Edge
func (RecursiveMixin[T]) Fields ¶
func (r RecursiveMixin[T]) Fields() []ent.Field
func (RecursiveMixin[T]) Hooks ¶
func (r RecursiveMixin[T]) Hooks() []ent.Hook
func (RecursiveMixin[T]) Indexes ¶
func (r RecursiveMixin[T]) Indexes() []ent.Index
func (RecursiveMixin[T]) Interceptors ¶
func (r RecursiveMixin[T]) Interceptors() []ent.Interceptor
func (RecursiveMixin[T]) Policy ¶
func (r RecursiveMixin[T]) Policy() ent.Policy
type ResourceMixin ¶
ResourceMixin adds common fields
func (ResourceMixin) Fields ¶
func (ResourceMixin) Fields() []ent.Field
func (ResourceMixin) Indexes ¶
func (ResourceMixin) Indexes() []ent.Index
type TimeMixinCreator ¶
type TimeMixinGetter ¶
type TimeMixinUpdater ¶
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 Self() T }
Able to use an existing transaction
type 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 ¶
type UniqueResourceMixin ¶
UniqueResourceMixin adds common fields
func (UniqueResourceMixin) Fields ¶
func (UniqueResourceMixin) Fields() []ent.Field
func (UniqueResourceMixin) Indexes ¶
func (UniqueResourceMixin) Indexes() []ent.Index