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 Execer
- type Getter
- type OffsetPageParams
- type Opts
- type Queryer
- type Selecter
- type Sort
- 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"` Order string `page:"order"` Limit uint64 `page:"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
type Databaser ¶
func NewDatabaser ¶
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 OffsetPageParams ¶
type OffsetPageParams struct { Limit uint64 `page:"limit" default:"15"` Order string `page:"order" default:"desc"` PageNumber uint64 `page:"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 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)
}