Documentation
¶
Index ¶
- func GetOrdering(order sortx.Order) []sql.OrderTermOption
- func GetPGDriver(databaseURL string) (*entDialectSQL.Driver, error)deprecated
- func JSONBIn(field string, key string, values []string) func(*sql.Selector)
- func NewTxContext(ctx context.Context, tx *TxDriver) context.Context
- func RunInTransaction[R any](txCtx context.Context, txDriver *TxDriver, ...) (*R, error)
- func StartAndRunTx[R any](ctx context.Context, src TxCreator, ...) (*R, error)
- type IDMixin
- type MetadataAnnotationsMixin
- type NamespaceMixin
- type RawEntConfig
- type TimeMixin
- type Transactable
- type TxCreator
- type TxDriver
- type TxDriverContextKey
- type TxHijacker
- type TxUser
- type ULID
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetOrdering ¶
func GetOrdering(order sortx.Order) []sql.OrderTermOption
func GetPGDriver
deprecated
func GetPGDriver(databaseURL string) (*entDialectSQL.Driver, error)
Deprecated: use NewEntPostgresDriver instead
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 RunInTransaction ¶
Types ¶
type MetadataAnnotationsMixin ¶
NamespaceMixin can be used for namespaced entities
func (MetadataAnnotationsMixin) Fields ¶
func (MetadataAnnotationsMixin) Fields() []ent.Field
Fields of the IDMixin.
type NamespaceMixin ¶
NamespaceMixin can be used for namespaced entities
type RawEntConfig ¶
type Transactable ¶
type TxCreator ¶
type TxCreator interface { // Creates a TxDriver from a hijacked ent transaction (the driver of it). // Example: // // type dbAdapter struct { // db *db.Client // } // // // we have to implement the TxCreator interface // func (d *dbAdapter) Tx(ctx context.Context) (context.Context, *entutils.TxDriver, error) { // // HijackTx gets generated when using expose.tpl // txCtx, rawConfig, eDriver, err := d.db.HijackTX(ctx, &sql.TxOptions{ // ReadOnly: false, // }) // // if err != nil { // return nil, nil, fmt.Errorf("failed to hijack transaction: %w", err) // } // return txCtx, entutils.NewTxDriver(eDriver, rawConfig), nil // } Tx(ctx context.Context) (context.Context, *TxDriver, error) }
Able to start a new transaction
type TxDriver ¶
type TxDriver struct {
// contains filtered or unexported fields
}
func NewTxDriver ¶
func NewTxDriver(driver Transactable, cfg *RawEntConfig) *TxDriver
func (*TxDriver) GetConfig ¶
func (t *TxDriver) GetConfig() *RawEntConfig
type TxDriverContextKey ¶
type TxDriverContextKey string
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