Documentation
¶
Index ¶
- func BulkInsert(db meddler.DB, q string, args interface{}) error
- func ConnectSQLDB(port int, host, user, password, name string) (*sqlx.DB, error)
- func InitSQLDB(port int, host, user, password, name string) (*sqlx.DB, error)
- func MigrationsDown(db *sql.DB) error
- func MigrationsUp(db *sql.DB) error
- func Rollback(txn *sqlx.Tx)
- func RowsClose(rows *sql.Rows)
- func SlicePtrsToSlice(slice interface{}) interface{}
- func SliceToSlicePtrs(slice interface{}) interface{}
- type APIConnectionController
- type BigIntMeddler
- type BigIntNullMeddler
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BulkInsert ¶
BulkInsert performs a bulk insert with a single statement into the specified table. Example: `db.BulkInsert(myDB, "INSERT INTO block (eth_block_num, timestamp, hash) VALUES %s", blocks[:])` Note that all the columns must be specified in the query, and they must be in the same order as in the table. Note that the fields in the structs need to be defined in the same order as in the table columns.
func ConnectSQLDB ¶
ConnectSQLDB connects to the SQL DB
func MigrationsDown ¶
MigrationsDown runs the SQL migrations Down
func SlicePtrsToSlice ¶
func SlicePtrsToSlice(slice interface{}) interface{}
SlicePtrsToSlice converts any []*Foo to []Foo
func SliceToSlicePtrs ¶
func SliceToSlicePtrs(slice interface{}) interface{}
SliceToSlicePtrs converts any []Foo to []*Foo
Types ¶
type APIConnectionController ¶
type APIConnectionController struct {
// contains filtered or unexported fields
}
APIConnectionController is used to limit the SQL open connections used by the API
func NewAPIConnectionController ¶
func NewAPIConnectionController(maxConnections int, timeout time.Duration) *APIConnectionController
NewAPIConnectionController initialize APIConnectionController
func (*APIConnectionController) Acquire ¶
func (acc *APIConnectionController) Acquire() (context.CancelFunc, error)
Acquire reserves a SQL connection. If the connection is not acquired within the timeout, the function will return an error
func (*APIConnectionController) Release ¶
func (acc *APIConnectionController) Release()
Release frees a SQL connection
type BigIntMeddler ¶
type BigIntMeddler struct{}
BigIntMeddler encodes or decodes the field value to or from JSON
func (BigIntMeddler) PostRead ¶
func (b BigIntMeddler) PostRead(fieldPtr, scanTarget interface{}) error
PostRead is called after a Scan operation for fields that have the BigIntMeddler
func (BigIntMeddler) PreRead ¶
func (b BigIntMeddler) PreRead(fieldAddr interface{}) (scanTarget interface{}, err error)
PreRead is called before a Scan operation for fields that have the BigIntMeddler
func (BigIntMeddler) PreWrite ¶
func (b BigIntMeddler) PreWrite(fieldPtr interface{}) (saveValue interface{}, err error)
PreWrite is called before an Insert or Update operation for fields that have the BigIntMeddler
type BigIntNullMeddler ¶
type BigIntNullMeddler struct{}
BigIntNullMeddler encodes or decodes the field value to or from JSON
func (BigIntNullMeddler) PostRead ¶
func (b BigIntNullMeddler) PostRead(fieldPtr, scanTarget interface{}) error
PostRead is called after a Scan operation for fields that have the BigIntNullMeddler
func (BigIntNullMeddler) PreRead ¶
func (b BigIntNullMeddler) PreRead(fieldAddr interface{}) (scanTarget interface{}, err error)
PreRead is called before a Scan operation for fields that have the BigIntNullMeddler
func (BigIntNullMeddler) PreWrite ¶
func (b BigIntNullMeddler) PreWrite(fieldPtr interface{}) (saveValue interface{}, err error)
PreWrite is called before an Insert or Update operation for fields that have the BigIntNullMeddler