database

package
v0.9.69 Latest Latest
Warning

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

Go to latest
Published: Sep 7, 2025 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) 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

type Database

type Database interface {
	Master() *gorm.DB
	Slave() *gorm.DB
	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