bolt

package
v0.1.20 Latest Latest
Warning

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

Go to latest
Published: Oct 18, 2022 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() error

func (*BoltSession) Close

func (this *BoltSession) Close() error

func (*BoltSession) Commit

func (this *BoltSession) Commit() error

func (*BoltSession) Complex

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

func (*BoltSession) Count

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

func (*BoltSession) Delete

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

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, error)

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, error)

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, error)

insert model data to database

func (*BoltSession) Query

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

execute sql and get result

func (*BoltSession) Rollback

func (this *BoltSession) Rollback() error

func (*BoltSession) Scan

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

scan result

func (*BoltSession) Sync

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

func (*BoltSession) Transaction

func (this *BoltSession) Transaction(fc func(s repository.DbSession) error) 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, error)

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