database

package
v0.0.0-...-833fa1d Latest Latest
Warning

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

Go to latest
Published: Apr 3, 2024 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	CtxDatabase    = struct{ s string }{"db"}
	CtxTransaction = struct{ s string }{"db:transaction"}
)

List of context keys

Functions

func ContextExecutor

func ContextExecutor(ctx context.Context, dbs ...*gorm.DB) *gorm.DB

ContextExecutor returns SQL executor from opened transaction or master connection

func ContextTransaction

func ContextTransaction(ctx context.Context, dbs ...*gorm.DB) (*gorm.DB, context.Context, bool, error)

ContextTransaction get or init new transaction and put object to the context

func ContextTransactionExec

func ContextTransactionExec(ctx context.Context, fn func(ctx context.Context, tx *gorm.DB) error, dbs ...*gorm.DB) error

ContextTransactionExec executes function in transaction

func Master

func Master(ctx context.Context) *gorm.DB

Master database conncetion

func Readonly

func Readonly(ctx context.Context) *gorm.DB

Readonly database conncetion

func WithDatabase

func WithDatabase(ctx context.Context, master, slave *gorm.DB) context.Context

WithDatabase puts databases to context

Types

This section is empty.

Jump to

Keyboard shortcuts

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