Documentation ¶
Index ¶
- Constants
- func IsConstraintErr(err error, name string) bool
- func JSONScan(src, dest interface{}) error
- func JSONValue(data interface{}) (driver.Value, error)
- type Connection
- type CursorPageParams
- type DB
- type Databaser
- type EventsListenerOpts
- type EventsRouter
- type EventsRouterOpts
- type Execer
- type Getter
- type Handler
- type OffsetPageParams
- type Opts
- type Queryer
- type Selecter
- type Sort
- type SortedOffsetPageParams
- type Sorts
- type TransactionFunc
- type Transactor
Constants ¶
const ( // OrderTypeAsc means result should be sorted in ascending order. OrderTypeAsc = "asc" // OrderTypeDesc means result should be sorted in descending order. OrderTypeDesc = "desc" )
Variables ¶
This section is empty.
Functions ¶
func IsConstraintErr ¶
Types ¶
type Connection ¶
type Connection interface { Transactor Queryer }
Connection is yet another thin wrapper for sql.DB allowing to use squirrel queries directly
type CursorPageParams ¶
type CursorPageParams struct { Cursor uint64 `page:"cursor" json:"cursor"` Order string `page:"order" json:"order"` Limit uint64 `page:"limit" json:"limit"` }
CursorPageParams - page params of the db query
func (*CursorPageParams) ApplyTo ¶
func (p *CursorPageParams) ApplyTo(sql squirrel.SelectBuilder, col string) squirrel.SelectBuilder
ApplyTo returns a new SelectBuilder after applying the paging effects of `p` to `sql`. This method provides the default case for paging: int64 cursor-based paging by an id column.
type DB ¶
type DB struct { Queryer // contains filtered or unexported fields }
func (*DB) Transaction ¶
func (db *DB) Transaction(fn TransactionFunc) (err error)
Transaction is generic helper method for specific Q's to implement Transaction capabilities
func (*DB) TransactionWithCtx ¶ added in v1.12.2
func (db *DB) TransactionWithCtx(ctx context.Context, funcs ...TransactionFunc) error
func (*DB) TransactionWithOptions ¶ added in v1.12.0
func (db *DB) TransactionWithOptions(opts *sql.TxOptions, fn TransactionFunc) (err error)
type EventsListenerOpts ¶ added in v1.12.0
type EventsListenerOpts struct { Log *logan.Entry Payload string // skip notifications from the channel if payload does not match. Empty string is treated as no filter is present TickPeriod time.Duration Handler Handler }
EventsListenerOpts - defines config for events listener
type EventsRouter ¶ added in v1.12.0
type EventsRouter interface {
RunNewListener(ctx context.Context, opts EventsListenerOpts)
}
EventsRouter - listens to events of postgres channel and sends notification to listeners
func NewEventsRouter ¶ added in v1.12.0
func NewEventsRouter(ctx context.Context, opts EventsRouterOpts) EventsRouter
NewEventsRouter - creates new EventsRouter and starts corresponding routines
type EventsRouterOpts ¶ added in v1.12.0
EventsRouterOpts - config for new EventsRouter
type Execer ¶
type Execer interface { Exec(query squirrel.Sqlizer) error ExecContext(ctx context.Context, query squirrel.Sqlizer) error ExecRaw(query string, args ...interface{}) error ExecRawContext(ctx context.Context, query string, args ...interface{}) error ExecWithResult(query squirrel.Sqlizer) (sql.Result, error) ExecWithResultContext(ctx context.Context, query squirrel.Sqlizer) (sql.Result, error) }
type Getter ¶
type Getter interface { Get(dest interface{}, query squirrel.Sqlizer) error GetContext(ctx context.Context, dest interface{}, query squirrel.Sqlizer) error GetRaw(dest interface{}, query string, args ...interface{}) error GetRawContext(ctx context.Context, dest interface{}, query string, args ...interface{}) error }
type Handler ¶ added in v1.12.0
Handler - handles notification of new event received form postgres or ticks
type OffsetPageParams ¶
type OffsetPageParams struct { Limit uint64 `page:"limit" default:"15" json:"limit"` Order string `page:"order" default:"desc" json:"order"` PageNumber uint64 `page:"number" json:"number"` }
OffsetPageParams defines page params for offset-based pagination.
func (*OffsetPageParams) ApplyTo ¶
func (p *OffsetPageParams) ApplyTo(sql squirrel.SelectBuilder, cols ...string) squirrel.SelectBuilder
ApplyTo returns a new SelectBuilder after applying the paging effects of `p` to `sql`.
type Selecter ¶
type Selecter interface { Select(dest interface{}, query squirrel.Sqlizer) error SelectContext(ctx context.Context, dest interface{}, query squirrel.Sqlizer) error SelectRaw(dest interface{}, query string, args ...interface{}) error SelectRawContext(ctx context.Context, dest interface{}, query string, args ...interface{}) error }
type SortedOffsetPageParams ¶ added in v1.12.0
type SortedOffsetPageParams struct { Limit uint64 `page:"limit" default:"15"` Sort []string `url:"sort"` PageNumber uint64 `page:"number"` }
OffsetPageParams defines page params for offset-based pagination.
func (*SortedOffsetPageParams) ApplyTo ¶ added in v1.12.0
func (p *SortedOffsetPageParams) ApplyTo(sql squirrel.SelectBuilder, columns map[string]string) squirrel.SelectBuilder
type Sorts ¶
type Sorts []Sort
Sorts is a slice of sorting params that can be applied directly to sql query.
func (Sorts) ApplyTo ¶
func (sorts Sorts) ApplyTo(stmt squirrel.SelectBuilder, columns map[string]string) squirrel.SelectBuilder
ApplyTo applies sorts to a prepared sql statement. Takes a map of <query-param>:<column> names (without minuses). Like:
map[string]string{}{ "created_at": "books.created_at", "author.name": "authors.name", }
Panics if sort parameter in a slice isn't provided in "columns" map.
type TransactionFunc ¶
type TransactionFunc func() error
type Transactor ¶
type Transactor interface {
Transaction(transactionFunc TransactionFunc) (err error)
}