db

package
v0.0.0-...-63ace11 Latest Latest
Warning

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

Go to latest
Published: Jun 3, 2022 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Delete

func Delete(pool *pool.DbPool, sql *string, args ...interface{}) (sql.Result, error)

for delete with param list bind with ?

"delete from person where id = ?"

func Insert

func Insert(pool *pool.DbPool, sql *string, args ...any) (sql.Result, error)

for insert with param list bind with ?

"INSERT INTO person (first_name, last_name, email) VALUES (?, ?, ?)"

func NamedDelete

func NamedDelete(pool *pool.DbPool, sql *string, args *map[string]interface{}) (sql.Result, error)

for delete with named param bind:

"delete from person where id = :id"

func NamedInsert

func NamedInsert(pool *pool.DbPool, sql *string, args *map[string]interface{}) (sql.Result, error)

for insert with named param bind:

"INSERT INTO person (first_name, last_name, email) VALUES (:first, :last, :email)"

func NamedUpdate

func NamedUpdate(pool *pool.DbPool, sql *string, args *map[string]interface{}) (sql.Result, error)

for update with named param bind:

"update person set first_name = :first, last_name = :last, email = :email where id = :id"

func NextSeqMargin

func NextSeqMargin(pool *pool.DbPool, sqlSelect *string, sqlUpdate *string, seqName string) (map[string]interface{}, error)

func SelectAsJson

func SelectAsJson(pool *pool.DbPool, sql *string, args ...interface{}) ([]byte, error)

func SelectAsJsonArray

func SelectAsJsonArray(pool *pool.DbPool, sql *string, args ...interface{}) ([]byte, error)

func SelectAsMap

func SelectAsMap(pool *pool.DbPool, sql *string, args ...interface{}) (map[string]interface{}, error)

for select single row, return result as map[string]interface{}

resMap, err := SelectAsMap(db, &slice, "SELECT * FROM person WHERE first_name=?", "Jason")

func SelectAsMapSlice

func SelectAsMapSlice(pool *pool.DbPool, sql *string, args ...interface{}) ([]interface{}, error)

for select multi row, return result as []map[string]interface{}

sliceMap, err := SelectAsMapSlice(db, sql, "SELECT * FROM person WHERE first_name=?", "Jason")

func SelectAsObject

func SelectAsObject(pool *pool.DbPool, outObject interface{}, sql *string, args ...interface{}) error

for select single row, return outObject automatic reflect to dest struct

obj := Person{}
err := crud.SelectAsObject(db, &obj, "SELECT * FROM person WHERE first_name=?", "Jason")

func SelectAsSlice

func SelectAsSlice(pool *pool.DbPool, outSlice interface{}, sql *string, args ...interface{}) error

for select multi rows, return outSlice automatic reflect to dest struct

slice := []Person{}
err := SelectAsSlice(db, &slice, "SELECT * FROM person ORDER BY first_name ASC")

func TxDelete

func TxDelete(pool *pool.DbPool, sql *string, args ...interface{}) (sql.Result, error)

func TxInsert

func TxInsert(pool *pool.DbPool, sql *string, args ...any) (sql.Result, error)

func TxNamedDelete

func TxNamedDelete(pool *pool.DbPool, sql *string, args *map[string]interface{}) (sql.Result, error)

func TxNamedInsert

func TxNamedInsert(pool *pool.DbPool, sql *string, args *map[string]interface{}) (sql.Result, error)

func TxNamedUpdate

func TxNamedUpdate(pool *pool.DbPool, sql *string, args *map[string]interface{}) (sql.Result, error)

func TxSelectAsMap

func TxSelectAsMap(pool *pool.DbPool, sql *string, args ...interface{}) (map[string]interface{}, error)

func TxSelectAsMapSlice

func TxSelectAsMapSlice(pool *pool.DbPool, sql *string, args ...interface{}) ([]interface{}, error)

func TxSelectAsObject

func TxSelectAsObject(pool *pool.DbPool, outObject interface{}, sql *string, args ...interface{}) error

func TxSelectAsSlice

func TxSelectAsSlice(pool *pool.DbPool, outSlice interface{}, sql *string, args ...interface{}) error

select with transaction

func TxUpdate

func TxUpdate(pool *pool.DbPool, sql *string, args ...interface{}) (sql.Result, error)

func Update

func Update(pool *pool.DbPool, sql *string, args ...interface{}) (sql.Result, error)

for update with param list bind with ?

"update person set first_name = ?, last_name = ?, email = ? where id = ?"

func UpdateOri

func UpdateOri(db *sqlx.DB, sql *string, args ...interface{}) (sql.Result, error)

Types

This section is empty.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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