bolt

package
v0.0.5 Latest Latest
Warning

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

Go to latest
Published: Feb 7, 2021 License: AGPL-3.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewBoltSession

func NewBoltSession() repository.DbSession

Types

type BoltSession

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

每次事务开始时创建新会话

func (*BoltSession) Begin

func (this *BoltSession) Begin()

func (*BoltSession) Close

func (this *BoltSession) Close()

func (*BoltSession) Commit

func (this *BoltSession) Commit()

func (*BoltSession) Complex

func (this *BoltSession) Complex(qb *repository.QueryBuilder, dest []interface{})

func (*BoltSession) Count

func (this *BoltSession) Count(bean interface{}, conds string, params ...interface{}) int64

func (*BoltSession) Delete

func (this *BoltSession) Delete(md interface{}, conds string, params ...interface{}) int64

delete model in database Delete records, bean's non-empty fields are conditions

func (*BoltSession) Exec

func (this *BoltSession) Exec(clause string, params ...interface{}) sql.Result

execute sql and get result

func (*BoltSession) Find

func (this *BoltSession) Find(rowsSlicePtr interface{}, md interface{}, orderby string, from int, limit int, conds string, params ...interface{}) error

Find retrieve records from table, condiBeans's non-empty fields are conditions. beans could be []Struct, []*Struct, map[int64]Struct map[int64]*Struct everyone := make([]Userinfo, 0) err := engine.Find(&everyone)

func (*BoltSession) Get

func (this *BoltSession) Get(dest interface{}, locked bool, orderby string, conds string, params ...interface{}) bool

Get retrieve one record from database, bean's non-empty fields will be as conditions

func (*BoltSession) Insert

func (this *BoltSession) Insert(mds ...interface{}) int64

insert model data to database

func (*BoltSession) Query

func (this *BoltSession) Query(clause string, params ...interface{}) []map[string][]byte

execute sql and get result

func (*BoltSession) Rollback

func (this *BoltSession) Rollback()

func (*BoltSession) Scan

func (this *BoltSession) Scan(dest interface{}) *BoltSession

scan result

func (*BoltSession) Sync

func (this *BoltSession) Sync(bean ...interface{})

func (*BoltSession) Transaction

func (this *BoltSession) Transaction(fc func(s repository.DbSession) error)

*

	Transaction 的 f 参数类型为 一个在事务内处理的函数
    因此可以将 f 函数作为参数传入 Transaction 函数中。
    return Transaction(func(s *XormSession) error {
        if _,error := session.Insert(User{ID:5,Version:"abc"}); error != nil{
            return error
        }
	})

func (*BoltSession) Update

func (this *BoltSession) Update(md interface{}, columns []string, conds string, params ...interface{}) int64

update model to database. cols set the columns those want to update.

Jump to

Keyboard shortcuts

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