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, []any)) error
- func IterateScanE(rows *sql.Rows, callback func([]string, []*sql.ColumnType, []any) error) error
- func PlaceholdersString(n int) string
- func StdConvert(src any, def *sql.ColumnType) any
- type CallbackDB
- type DurationNanos
- type Executor
- type GenericListReader
- type GenericReader
- type Getter
- type JSON
- type Querier
- type QuerierExecutor
- type Reader
- type ReaderExecutor
- type Rowset
- func (r *Rowset) Clear()
- func (r Rowset) Each(f func([]string, []*sql.ColumnType, []any))
- func (r Rowset) MapValues(f func(src any, def *sql.ColumnType) any) 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]any)
- type Selector
- type TrueFalse
- type UnixMillis
- 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 ErrDurationNanosUnsupportedType = errors.New("unsupported type")
var ErrJSONUnsupportedType = errors.New("unsupported type")
var ErrUnixMillisUnsupportedType = errors.New("unsupported type")
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
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 any, def *sql.ColumnType) any
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 any, query string, args ...any) error OnSelect func(dest any, query string, args ...any) error OnExec func(query string, args ...any) (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
type DurationNanos ¶ added in v1.7.2
type DurationNanos int64
DurationNanos is type duration in nanoseconds
func (DurationNanos) Duration ¶ added in v1.7.2
func (u DurationNanos) Duration() time.Duration
Duration returns Go's duration type
func (DurationNanos) Int64 ¶ added in v1.7.2
func (u DurationNanos) Int64() int64
Int64 returns nanoseconds count
func (DurationNanos) NativeSQL ¶ added in v1.7.2
func (u DurationNanos) NativeSQL() any
NativeSQL returns data in SQL native format
func (*DurationNanos) Scan ¶ added in v1.7.2
func (u *DurationNanos) Scan(src any) error
Scan is sql.Scanner interface implementation
func (DurationNanos) String ¶ added in v1.7.2
func (u DurationNanos) String() string
String return string representation of time in UTC
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 JSON ¶ added in v1.7.2
type JSON string
JSON wraps value stored in JSON format
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 [][]any }
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, []any))
Each iterated over each row, passing it with corresponding metadata to callback 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)
type UnixMillis ¶ added in v1.7.2
type UnixMillis int64
UnixMillis is type containing timestamp in unix milliseconds
func (UnixMillis) Int64 ¶ added in v1.7.2
func (u UnixMillis) Int64() int64
Int64 returns unix milliseconds as int64
func (UnixMillis) NativeSQL ¶ added in v1.7.2
func (u UnixMillis) NativeSQL() any
NativeSQL returns data in SQL native format
func (*UnixMillis) Scan ¶ added in v1.7.2
func (u *UnixMillis) Scan(src any) error
Scan is sql.Scanner interface implementation
func (UnixMillis) String ¶ added in v1.7.2
func (u UnixMillis) String() string
String return string representation of time in UTC
func (UnixMillis) Time ¶ added in v1.7.2
func (u UnixMillis) Time() time.Time
Time return unix milliseconds formatted as UTC time
type UnixSeconds ¶
type UnixSeconds int64
UnixSeconds is type containing timestamp in unix seconds
func (UnixSeconds) NativeSQL ¶
func (u UnixSeconds) NativeSQL() any
NativeSQL returns data in SQL native format
func (*UnixSeconds) Scan ¶
func (u *UnixSeconds) Scan(src any) 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