Documentation
¶
Index ¶
- func GetPGDriver(databaseURL string) (*entDialectSQL.Driver, error)
- 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 TxHijacker
- type TxUser
- type ULID
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetPGDriver ¶
func GetPGDriver(databaseURL string) (*entDialectSQL.Driver, error)
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 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 ¶
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 ¶
Click to show internal directories.
Click to hide internal directories.