Help us shape the future of Go! Take the 2026 Go Developer Survey

database

package
v0.9.82 Latest Latest
Warning

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

Go to latest
Published: Sep 14, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BaseRepository

type BaseRepository struct {
	// contains filtered or unexported fields
}

func NewBaseRepository

func NewBaseRepository(db Database) *BaseRepository

func (*BaseRepository) Begin

func (r *BaseRepository) Begin(
	ctx context.Context, isolationLvl sql.IsolationLevel,
) (context.Context, error)

func (*BaseRepository) Commit

func (r *BaseRepository) Commit(ctx context.Context) error

func (*BaseRepository) GetReadDB

func (r *BaseRepository) GetReadDB(ctx context.Context) *gorm.DB

func (*BaseRepository) GetTx

func (r *BaseRepository) GetTx(ctx context.Context) *gorm.DB

func (*BaseRepository) InTransaction

func (r *BaseRepository) InTransaction(ctx context.Context) bool

func (*BaseRepository) IsDuplicateKeyError

func (r *BaseRepository) IsDuplicateKeyError(err error) bool

func (*BaseRepository) IsNotFoundError

func (r *BaseRepository) IsNotFoundError(err error) bool

func (*BaseRepository) Rollback

func (r *BaseRepository) Rollback(ctx context.Context) error

func (*BaseRepository) WithTransaction

func (r *BaseRepository) WithTransaction(ctx context.Context, fn func(txCtx context.Context) error) error

func (*BaseRepository) WithTransactionIsolation added in v0.9.80

func (r *BaseRepository) WithTransactionIsolation(
	ctx context.Context, isolationLvl sql.IsolationLevel, fn func(txCtx context.Context) error,
) error

type Database

type Database interface {
	Master() *gorm.DB
	Slave() *gorm.DB
	Ping(ctx context.Context) error
	Shutdown(ctx context.Context) error
	IsNotFoundError(err error) bool
	IsDuplicateKeyError(err error) bool
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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