stdent

package
v0.0.27 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 18, 2025 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package stdent provides re-usable code for interacting with the Ent orm.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type HookDriver

type HookDriver struct {
	entdialect.Driver
	// contains filtered or unexported fields
}

HookDriver is an Ent driver that wraps a base driver to allow a hook to be configured for every transaction that is started. Useful for sql settings scoped to the transaction such as the current_user_id, or the role.

func NewTxHookDriver

func NewTxHookDriver(base entdialect.Driver, hook TxHookFunc) *HookDriver

func (HookDriver) BeginTx

func (d HookDriver) BeginTx(ctx context.Context, opts *sql.TxOptions) (entdialect.Tx, error)

BeginTx calls the base driver's method if it's supported and calls our hook.

func (HookDriver) Tx

Tx calls the base driver's method with the same symbol and invokes our hook.

type TxHookFunc

type TxHookFunc func(ctx context.Context, tx entdialect.Tx) error

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL