Documentation ¶
Index ¶
- Constants
- func GroupedStringToIntArray(groupedValue sql.NullString, separator string) []int64
- func GroupedStringToStringArray(groupedValue sql.NullString, separator string) []string
- func GroupedStringToUintArray(groupedValue sql.NullString, separator string) []uint64
- func IpV4ToBytesForLike(ip string) ([]byte, error)
- func IsPartialIpV4(ip string) bool
- func PanicIfError(err error)
- type Bytes16
- type DbCallback
- type DbCallbackFunc
- type DbConfig
- type DbController
- func (dbController *DbController) Exec(query string, args ...interface{}) sql.Result
- func (dbController *DbController) ExecQueriesInTx(queries ...string)
- func (dbController *DbController) InTx(txCallback TxCallback)
- func (dbController *DbController) InTxForIf(ifCallbacks ExecuteIfByTx)
- func (dbController *DbController) OperateOnDb(dbCallback DbCallback)
- func (dbController *DbController) QueryForRow(rowCallback RowCallback, sqlQuery string, args ...interface{})
- func (dbController *DbController) QueryForRows(rowsCallback RowsCallback, sqlQuery string, args ...interface{}) (numberOfRows uint)
- func (dbController *DbController) RegisterPanicHandler(panicHandler utils.PanicHandler)
- func (dbController *DbController) Release()
- type DbError
- type DbUuid
- type ExecuteIfByTx
- type GraphEndpoint
- type GraphEndpointCounter
- type GraphTagEndpoint
- type IterateControl
- type ResultExt
- type RowCallback
- type RowCallbackFunc
- type RowExt
- type RowsCallback
- type RowsCallbackFunc
- type RowsExt
- type StmtExt
- type TxCallback
- type TxCallbackFunc
- type TxExt
- type TxFinale
Constants ¶
const ( IterateContinue = IterateControl(1) IterateStop = IterateControl(0) )
Variables ¶
This section is empty.
Functions ¶
func GroupedStringToIntArray ¶
func GroupedStringToIntArray(groupedValue sql.NullString, separator string) []int64
Converts grouped string to array of int64
groupedValue - The grouped value retrieved from database, could be null separator - The separator
func GroupedStringToStringArray ¶
func GroupedStringToStringArray(groupedValue sql.NullString, separator string) []string
Converts grouped string to array of string
groupedValue - The grouped value retrieved from database, could be null separator - The separator
func GroupedStringToUintArray ¶
func GroupedStringToUintArray(groupedValue sql.NullString, separator string) []uint64
Converts grouped string to array of uint64
groupedValue - The grouped value retrieved from database, could be null separator - The separator
func IpV4ToBytesForLike ¶
Converts IPv4 address of string to byte array could be used in SQL.
Types ¶
type DbCallback ¶
The interface of DB callback for sql package
type DbCallbackFunc ¶
The function object delegates the DbCallback interface
func (DbCallbackFunc) OnDb ¶
func (f DbCallbackFunc) OnDb(db *sql.DB)
type DbController ¶
type DbController struct {
// contains filtered or unexported fields
}
Main controller of database
func NewDbController ¶
func NewDbController(newDbObject *sql.DB) *DbController
Initialize a controller for database
Without RegisterPanicHandler() any PanicHandler, The raised panic would be re-paniced.
func (*DbController) Exec ¶
func (dbController *DbController) Exec(query string, args ...interface{}) sql.Result
Executes the query string or panic
func (*DbController) ExecQueriesInTx ¶
func (dbController *DbController) ExecQueriesInTx(queries ...string)
Executes in transaction
func (*DbController) InTx ¶
func (dbController *DbController) InTx(txCallback TxCallback)
Executes in transaction.
This method would commit the transaction if there is no raised panic, rollback it otherwise.
func (*DbController) InTxForIf ¶
func (dbController *DbController) InTxForIf(ifCallbacks ExecuteIfByTx)
Executes the complex statement in transaction
func (*DbController) OperateOnDb ¶
func (dbController *DbController) OperateOnDb(dbCallback DbCallback)
Operate on database
func (*DbController) QueryForRow ¶
func (dbController *DbController) QueryForRow( rowCallback RowCallback, sqlQuery string, args ...interface{}, )
Query for a row and get called if the query is not failed
func (*DbController) QueryForRows ¶
func (dbController *DbController) QueryForRows( rowsCallback RowsCallback, sqlQuery string, args ...interface{}, ) (numberOfRows uint)
Query for rows and get called of rows with Next()
func (*DbController) RegisterPanicHandler ¶
func (dbController *DbController) RegisterPanicHandler(panicHandler utils.PanicHandler)
Registers a handler while a panic is raised
This object may register multiple handlers for panic
func (*DbController) Release ¶
func (dbController *DbController) Release()
Releases the database object under this object
As of service application(web, daemon...), this method is rarely get called
type DbUuid ¶
type DbUuid uuid.UUID
Uses the []byte for database/sql/driver.Value
type ExecuteIfByTx ¶
type ExecuteIfByTx interface { // First calling of database for boolean result BootCallback(tx *sql.Tx) bool // If the boot callback has true result, this callback would get called IfTrue(tx *sql.Tx) }
Executes callbacks in transaction if the boot callback has true value
type GraphEndpointCounter ¶
graph.endpoint_counter
type GraphTagEndpoint ¶
graph.tag_endpoint
type ResultExt ¶
type ResultExt struct {
// contains filtered or unexported fields
}
Extension for sql.Result
func (*ResultExt) LastInsertId ¶
Gets last id of insert with panic instead of returned error
func (*ResultExt) RowsAffected ¶
Gets last number of affected rows with panic instead of returned error
type RowCallback ¶
The interface of row callback for sql package
type RowCallbackFunc ¶
The function object delegates the RowCallback interface
func (RowCallbackFunc) ResultRow ¶
func (callbackFunc RowCallbackFunc) ResultRow(row *sql.Row)
type RowsCallback ¶
type RowsCallback interface {
NextRow(row *sql.Rows) IterateControl
}
The interface of rows callback for sql package
type RowsCallbackFunc ¶
type RowsCallbackFunc func(*sql.Rows) IterateControl
The function object delegates the RowsCallback interface
func (RowsCallbackFunc) NextRow ¶
func (callbackFunc RowsCallbackFunc) NextRow(rows *sql.Rows) IterateControl
type RowsExt ¶
Extension for sql.Rows
type TxCallback ¶
The interface of transaction callback for sql package
func BuildTxForSqls ¶
func BuildTxForSqls(queries ...string) TxCallback
BuildTxForSqls builds function for exeuction of multiple SQLs
type TxCallbackFunc ¶
The function object delegates the TxCallback interface