operation

package
v1.1.5 Latest Latest
Warning

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

Go to latest
Published: Oct 28, 2022 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetSql

func GetSql(sql *strings.Builder, params []*entity.Condition) (string, []interface{})

GetSql Splice sql with conditions

func GetUpdateSql

func GetUpdateSql(sql *strings.Builder, data map[string]interface{}, params []*entity.Condition) (string, []interface{})

GetUpdateSql Get the sql of update

func SqlConvert

func SqlConvert(sql string, params map[string]interface{}) (string, []interface{})

SqlConvert Replace the {} placeholder in sql with the ? placeholder, and convert the parameter to []interface{}

Types

type DBTemplate

type DBTemplate struct {
	DataSourceName string
	TxId           uint64
}

func GetDBTemplate

func GetDBTemplate(dataSourceName string) *DBTemplate

GetDBTemplate Get templates for database operations that do not require transactions

func GetDBTemplateTx

func GetDBTemplateTx(txId uint64, dataSourceName string) *DBTemplate

GetDBTemplateTx Get templates for database operations that require transactions

func (*DBTemplate) Delete

func (template *DBTemplate) Delete(tableName string, params []*entity.Condition) (sql.Result, error)

Delete No sql delete

func (*DBTemplate) DeleteTx

func (template *DBTemplate) DeleteTx(tableName string, params []*entity.Condition) (sql.Result, error)

DeleteTx No sql delete with transactions

func (*DBTemplate) Exec

func (template *DBTemplate) Exec(sql string, params []interface{}) (sql.Result, error)

Exec Add, delete and change operations

func (*DBTemplate) ExecByMap

func (template *DBTemplate) ExecByMap(sql string, paramsStruct map[string]interface{}) (sql.Result, error)

ExecByMap Add, delete and change operations based on the structure parameters

func (*DBTemplate) ExecByTx

func (template *DBTemplate) ExecByTx(sql string, params []interface{}) (sql.Result, error)

ExecByTx Add, delete and change operations with transactions

func (*DBTemplate) ExecByTxMap

func (template *DBTemplate) ExecByTxMap(sql string, paramsStruct map[string]interface{}) (sql.Result, error)

ExecByTxMap Add, delete and change operations with transactions based on structure parameters

func (*DBTemplate) ExecByTxNoParameters

func (template *DBTemplate) ExecByTxNoParameters(sql string) (sql.Result, error)

ExecByTxNoParameters Add, delete and change operations with transactions

func (*DBTemplate) ExecNoParameters

func (template *DBTemplate) ExecNoParameters(sql string) (sql.Result, error)

ExecNoParameters Add, delete and change operations

func (*DBTemplate) Insert

func (template *DBTemplate) Insert(tableName string, data map[string]interface{}) (sql.Result, error)

Insert No sql insert

func (*DBTemplate) InsertTx

func (template *DBTemplate) InsertTx(tableName string, data map[string]interface{}) (sql.Result, error)

InsertTx No sql insert with transactions

func (*DBTemplate) Select

func (template *DBTemplate) Select(tableName string, params []*entity.Condition) ([]map[string]string, error)

Select No sql query

func (*DBTemplate) SelectList

func (template *DBTemplate) SelectList(sql string, params []interface{}) ([]map[string]string, error)

SelectList Query and return a list

func (*DBTemplate) SelectListByMap

func (template *DBTemplate) SelectListByMap(sql string, paramsStruct map[string]interface{}) ([]map[string]string, error)

SelectListByMap Query by structure parameters

func (*DBTemplate) SelectListNoParameters

func (template *DBTemplate) SelectListNoParameters(sql string) ([]map[string]string, error)

SelectListNoParameters Query and return a list

func (*DBTemplate) SelectNoParameters

func (template *DBTemplate) SelectNoParameters(tableName string) ([]map[string]string, error)

SelectNoParameters No sql query no parameters

func (*DBTemplate) SelectOne

func (template *DBTemplate) SelectOne(sql string, params []interface{}) (map[string]string, error)

SelectOne Query and return a piece of data

func (*DBTemplate) SelectOneByMap

func (template *DBTemplate) SelectOneByMap(sql string, paramsStruct map[string]interface{}) (map[string]string, error)

SelectOneByMap Query and return a piece of data by structure parameters

func (*DBTemplate) SelectOneNoParameters

func (template *DBTemplate) SelectOneNoParameters(sql string) (map[string]string, error)

SelectOneNoParameters Query and return a piece of data

func (*DBTemplate) SelectPage

func (template *DBTemplate) SelectPage(sql string, pageParam entity.PageParam) (*entity.PageResult, error)

SelectPage Paging queries

func (*DBTemplate) SelectPageCustomCount

func (template *DBTemplate) SelectPageCustomCount(sql string, countSql string, pageParam entity.PageParam) (*entity.PageResult, error)

SelectPageCustomCount Paging queries, custom countSql

func (*DBTemplate) Update

func (template *DBTemplate) Update(tableName string, data map[string]interface{}, params []*entity.Condition) (sql.Result, error)

Update No sql update

func (*DBTemplate) UpdateTx

func (template *DBTemplate) UpdateTx(tableName string, data map[string]interface{}, params []*entity.Condition) (sql.Result, error)

UpdateTx No sql update with transactions

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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