gormx

package module
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Oct 23, 2022 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrNotInTransaction is returned when using Commit
	// outside of a transaction.
	ErrNotInTransaction = errors.New("not in transaction")

	// ErrIncompatibleOption is returned when using an option incompatible
	// with the selected driver.
	ErrIncompatibleOption = errors.New("incompatible option")

	// ErrInvalidGormDB is returned when a nil Gorm DB is used to
	// initialise Gormx
	ErrInvalidGormDB = errors.New("invalid Gorm DB")

	// ErrInvalidGormDBConfig is returned when a nil Gorm DB config is used to
	// initialise Gormx
	ErrInvalidGormDBConfig = errors.New("invalid Gorm DB config")
)

Functions

This section is empty.

Types

type Gormx

type Gormx interface {
	// Ping tests the underlying sql connection.
	Ping() error
	// Close the underlying sql connection.
	Close() error
	// Begin a new transaction.
	Beginx() *gormx
	// Begin a new transaction using the provided context and options.
	// Note that the provided parameters are only used when opening a new transaction,
	// not on nested ones.
	BeginTxx(ctx context.Context) *gormx
	// Rollback the associated transaction.
	Rollbackx() error
	// Commit the assiociated transaction.
	Commitx() error
	// Gorm returns the underlying Gorm DB.
	Gorm() *gorm.DB
	// Tx returns the underlying transaction.
	Tx() *gorm.DB
}

Gormx is a gorm db wrapper that can manage nested transactions.

func Connect

func Connect(dataSourceName string, config *gorm.Config) (Gormx, error)

Connect to a database.

func New

func New(gorm *gorm.DB) (Gormx, error)

New creates a new Gormx with the given DB.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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