database

package
v0.0.0-...-d5737d5 Latest Latest
Warning

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

Go to latest
Published: Jun 15, 2020 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrNotOpen = errors.New("database not open")

Functions

This section is empty.

Types

type DB

type DB struct {
	sync.Mutex
	// contains filtered or unexported fields
}

func New

func New(cfg config.Loader, log logger.Logger) *DB

func (*DB) Begin

func (d *DB) Begin(ctx context.Context, opts ...*sql.TxOptions) *gorm.DB

Begin begins a transaction

func (*DB) Create

func (d *DB) Create(ctx context.Context, model interface{}) *gorm.DB

func (*DB) Exec

func (d *DB) Exec(ctx context.Context, sql string, values ...interface{}) *gorm.DB

Exec execute raw sql

func (*DB) GetDB

func (d *DB) GetDB(ctx context.Context) *gorm.DB

func (*DB) Init

func (d *DB) Init(ctx context.Context) error

func (*DB) Key

func (d *DB) Key() string

func (*DB) Model

func (d *DB) Model(ctx context.Context, model interface{}) *gorm.DB

func (*DB) OnUpdate

func (d *DB) OnUpdate(key string, val string)

func (*DB) Ping

func (d *DB) Ping(ctx context.Context) error

func (*DB) Raw

func (d *DB) Raw(ctx context.Context, sql string, values ...interface{}) *gorm.DB

func (*DB) Table

func (d *DB) Table(ctx context.Context, table string) *gorm.DB

func (*DB) Transaction

func (d *DB) Transaction(ctx context.Context, fc func(tx *gorm.DB) error, opts ...*sql.TxOptions) (err error)

Transaction start a transaction as a block, return error will rollback, otherwise to commit.

func (*DB) Update

func (d *DB) Update(ctx context.Context, model interface{}) *gorm.DB

Jump to

Keyboard shortcuts

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