basesql

package
v0.0.0-...-48972bb Latest Latest
Warning

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

Go to latest
Published: Jan 8, 2019 License: MIT Imports: 10 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) Delete

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

Delete delete records

func (*Basesql) Excute

func (bs *Basesql) Excute(stmt *sql.Stmt, fields []database.Feild) (sql.Result, error)

func (*Basesql) GetInitSQLs

func (bs *Basesql) GetInitSQLs() (qt, qi []string)

GetInitSQLs get database initialize sqls

qt  sqls to create query tables
qi  sqls to create query table-indexs

func (*Basesql) Init

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

Init initialization

init db connection
create tables if not exist

func (*Basesql) Insert

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

Insert insert a record

func (*Basesql) Prepare

func (bs *Basesql) Prepare(table string, fields []database.Feild) (*sql.Stmt, error)

func (*Basesql) PrepareTables

func (bs *Basesql) PrepareTables(ctsqls, cisqls []string) error

PrepareTables create tables if not exists

func (*Basesql) Rollback

func (bs *Basesql) Rollback() error

Rollback rollback current transaction

func (*Basesql) SelectRawSQL

func (bs *Basesql) SelectRawSQL(table string, sqlStr string, values []interface{}, result interface{}) error

SelectRawSQL query useing raw sql

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

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

func (*Basesql) SelectRowsUnion

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

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