basesql

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Dec 10, 2018 License: LGPL-3.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Basesql

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

Basesql sql-like database

is not goroutine-safe

func (*Basesql) Begin

func (bs *Basesql) Begin() error

Begin begin a new transaction

func (*Basesql) Close

func (bs *Basesql) Close()

Close close conn

func (*Basesql) Commit

func (bs *Basesql) Commit() error

Commit commit current transaction

func (*Basesql) Count

func (bs *Basesql) Count(table string, where []database.Where) (int, error)

Count count records

func (*Basesql) Delete

func (bs *Basesql) Delete(table string, where []database.Where) (sql.Result, error)

Delete delete records

func (*Basesql) Init

func (bs *Basesql) Init(dbname string, cfg *viper.Viper, logger *zap.Logger) error

Init initialization

init db connection

func (*Basesql) InitTables

func (bs *Basesql) InitTables(tables, indexs []string) error

InitTables create tables and indexs if not exists

func (*Basesql) Insert

func (bs *Basesql) Insert(table string, feilds []database.Feild) (sql.Result, error)

Insert insert a record

func (*Basesql) Replace

func (bs *Basesql) Replace(table string, feilds []database.Feild) (sql.Result, error)

Replace insert or replace a record

func (*Basesql) Rollback

func (bs *Basesql) Rollback() error

Rollback rollback current transaction

func (*Basesql) SelectRows

func (bs *Basesql) SelectRows(table string, where []database.Where, order *database.Order, paging *database.Paging, result interface{}) error

SelectRows select rows to struct slice, using "xxx > xxx" as paging method

func (*Basesql) SelectRowsOffset

func (bs *Basesql) SelectRowsOffset(table string, where []database.Where, order *database.Order, offset, limit uint64, result interface{}) error

SelectRowsOffset select rows to struct slice, using "limit xxx offset xxx" as paging method

func (*Basesql) Update

func (bs *Basesql) Update(table string, toupdate []database.Feild, where []database.Where) (sql.Result, error)

Update update records

Jump to

Keyboard shortcuts

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