Documentation
¶
Index ¶
- Variables
- func InsertID(result sql.Result, err error) (int64, error)
- func InsertIDU(result sql.Result, err error) (uint64, error)
- func IterateScan(rows *sql.Rows, callback func([]string, []*sql.ColumnType, []interface{})) error
- func IterateScanE(rows *sql.Rows, ...) error
- func PlaceholdersString(n int) string
- func StdConvert(src interface{}, def *sql.ColumnType) interface{}
- type CallbackDB
- type Executor
- type GenericListReader
- type GenericReader
- type Getter
- type Querier
- type QuerierExecutor
- type Reader
- type ReaderExecutor
- type Rowset
- func (r *Rowset) Clear()
- func (r Rowset) Each(f func([]string, []*sql.ColumnType, []interface{}))
- func (r Rowset) MapValues(f func(src interface{}, def *sql.ColumnType) interface{}) Rowset
- func (r Rowset) MapValuesStd() Rowset
- func (r *Rowset) Scan(rows *sql.Rows) error
- func (r Rowset) Size() int
- func (r Rowset) SliceMap() (out []map[string]interface{})
- type Selector
- type TrueFalse
- type UnixSeconds
Constants ¶
This section is empty.
Variables ¶
var ErrCallbackNotSet = errors.New("callback not set")
ErrCallbackNotSet is returned by CallbackDB when callback for corresponding method not set.
var ErrUnixSecondsUnsupportedType = errors.New("unsupported type")
Functions ¶
func IterateScan ¶
IterateScan scans given rows ony by one passing obtained data to callback function.
func IterateScanE ¶ added in v1.6.0
func IterateScanE(rows *sql.Rows, callback func([]string, []*sql.ColumnType, []interface{}) error) error
IterateScanE scans given rows ony by one passing obtained data to callback function. On any error stops iteration and returns it.
func PlaceholdersString ¶ added in v1.6.0
PlaceholdersString constructs placeholders string like ?,?,?
func StdConvert ¶
func StdConvert(src interface{}, def *sql.ColumnType) interface{}
StdConvert performs conversion from interface{} to defined in sql.ColumnType type using standard ruleset.
Types ¶
type CallbackDB ¶ added in v1.2.1
type CallbackDB struct {
OnGet func(dest interface{}, query string, args ...interface{}) error
OnSelect func(dest interface{}, query string, args ...interface{}) error
OnExec func(query string, args ...interface{}) (sql.Result, error)
}
CallbackDB is the simplest implementation of ReaderExecutor interface providing to configure which function will be invoked on corresponding method. This can be useful in unit tests
func (CallbackDB) Exec ¶ added in v1.2.1
func (c CallbackDB) Exec(query string, args ...interface{}) (sql.Result, error)
Exec is Executor interface implementation
func (CallbackDB) Get ¶ added in v1.2.1
func (c CallbackDB) Get(dest interface{}, query string, args ...interface{}) error
Get is Getter interface implementation
func (CallbackDB) Select ¶ added in v1.2.1
func (c CallbackDB) Select(dest interface{}, query string, args ...interface{}) error
Select is Selector interface implementation
type GenericListReader ¶ added in v1.6.0
GenericListReader defines accessor to database providing ability to read list(slice) of records of type [T] using slice of identifiers of type [I]
type GenericReader ¶ added in v1.6.0
GenericReader defines accessor to database providing ability to read single entity of type [T] using identifier with type [I]
type Querier ¶ added in v1.5.0
Querier is a thin interface for database connection capable to query data
type QuerierExecutor ¶ added in v1.6.0
QuerierExecutor is a thin interface for database connection capable to both read and write data
type ReaderExecutor ¶
ReaderExecutor is a thin interface for database connection capable to both read and write data
type Rowset ¶
type Rowset struct {
ColumnNames []string
ColumnTypes []*sql.ColumnType
Rows [][]interface{}
}
Rowset is plain two-dimensional data table containing data, obtained from SQL database in non-structured way (via interface{})
func (Rowset) Each ¶
func (r Rowset) Each(f func([]string, []*sql.ColumnType, []interface{}))
Each iterated over each row, passing it with corresponding metadata to callback function.
func (Rowset) MapValues ¶
func (r Rowset) MapValues(f func(src interface{}, def *sql.ColumnType) interface{}) Rowset
MapValues maps all values in rowset using given conversion function.
func (Rowset) MapValuesStd ¶
MapValuesStd maps all values in rowset using standard conversion function.
type TrueFalse ¶
type TrueFalse bool
TrueFalse wraps values stored in database as enum(true,false)
func (TrueFalse) NativeSQL ¶
func (t TrueFalse) NativeSQL() interface{}
NativeSQL returns data in SQL native format
type UnixSeconds ¶
type UnixSeconds int64
UnixSeconds is type containing timestamp in unix seconds
func (UnixSeconds) NativeSQL ¶
func (u UnixSeconds) NativeSQL() interface{}
NativeSQL returns data in SQL native format
func (*UnixSeconds) Scan ¶
func (u *UnixSeconds) Scan(src interface{}) error
Scan is sql.Scanner interface implementation
func (UnixSeconds) String ¶
func (u UnixSeconds) String() string
String return string representation of time in UTC
func (UnixSeconds) Time ¶
func (u UnixSeconds) Time() time.Time
Time return unix seconds formatted as UTC time