Documentation
¶
Index ¶
- Constants
- Variables
- func ApplyOperators(query *squirrel.SelectBuilder, config []ISearchOperatorConfig, ...)
- func ApplySort(activeSorts []string, query *squirrel.SelectBuilder, ...)
- func ApplySortStrings(xs []string, query *squirrel.SelectBuilder, sorts map[string]string)
- func Delete(db sqlx.Ext, qry squirrel.DeleteBuilder) error
- func DeleteWhere(db sqlx.Ext, table string, where interface{}) error
- func GetForStruct(db sqlx.Queryer, val interface{}, table string, where interface{}) error
- func InsertReturningId(db sqlx.Ext, qry squirrel.InsertBuilder, id interface{}) error
- func InsertSetMapNoId(db sqlx.Ext, table string, payload interface{}) error
- func InsertSetMapReturningId(db sqlx.Ext, table string, payload interface{}, id interface{}) error
- func SelectForStruct(db sqlx.Queryer, slice interface{}, table string, where interface{}) error
- func TransformError(err error, cfg map[ErrorConfig]error) error
- func Update(db sqlx.Ext, qry squirrel.UpdateBuilder) error
- func UpdateSetMap(db sqlx.Ext, table string, payload, where interface{}) error
- type Accumulator
- type Byte
- type Direction
- type ErrorConfig
- type ExtendedSort
- type ISearchOperatorConfig
- type MatchesCode
- type MatchesConstraint
- type MatchesRoutine
- type SearchOperatorConfigBase
- type SearchOperatorConfigBool
- type SearchOperatorConfigStringLike
- type SearchOperatorConfigUUID
- type SimpleSort
- type Sort
Constants ¶
Variables ¶
View Source
var (
ErrByteFormatError = errors.New("unexpected format. Expecting a bit array")
)
View Source
var Psql = squirrel.StatementBuilder.PlaceholderFormat(squirrel.Dollar)
Functions ¶
func ApplyOperators ¶
func ApplyOperators(query *squirrel.SelectBuilder, config []ISearchOperatorConfig, ops operator.Operators, prefix string)
func ApplySort ¶
func ApplySort(activeSorts []string, query *squirrel.SelectBuilder, possibleSorts map[string]Sort)
func ApplySortStrings ¶
func ApplySortStrings(xs []string, query *squirrel.SelectBuilder, sorts map[string]string)
func GetForStruct ¶
func InsertReturningId ¶
func InsertReturningId(db sqlx.Ext, qry squirrel.InsertBuilder, id interface{}) error
func InsertSetMapReturningId ¶
func SelectForStruct ¶
func TransformError ¶
func TransformError(err error, cfg map[ErrorConfig]error) error
Transforms the error coming in *if* it is a PG error, based on the configuration.
Usage:
cfg := map[ErrorConfig]error{ MatchesConstraint("id_fkey"): ErrInvalidId, } ... _, err := db.Exec(....) return TransformError(err, cfg)
Types ¶
type Accumulator ¶
type Accumulator struct {
// contains filtered or unexported fields
}
func (*Accumulator) ApplyAnd ¶
func (a *Accumulator) ApplyAnd(sql squirrel.Sqlizer)
func (*Accumulator) ApplyOr ¶
func (a *Accumulator) ApplyOr(sql squirrel.Sqlizer)
func (*Accumulator) ApplyRemainder ¶
func (a *Accumulator) ApplyRemainder(sql squirrel.Sqlizer)
func (*Accumulator) ApplyToQuery ¶
func (a *Accumulator) ApplyToQuery(query *squirrel.SelectBuilder)
func (*Accumulator) GetCondition ¶
func (a *Accumulator) GetCondition() squirrel.Sqlizer
type Byte ¶
type Byte uint8
Postgres Binary requires a specific format when writing and reading. This is used to write and read it properly.
type ErrorConfig ¶
type ExtendedSort ¶
type ExtendedSort struct { Field SimpleSort SecondarySorts []string }
func (ExtendedSort) String ¶
func (s ExtendedSort) String(key string) string
type ISearchOperatorConfig ¶
type ISearchOperatorConfig interface { Apply(o, rem []operator.Operator, a *Accumulator, prefix string) GetKeys() []string }
configuration for different searches.
type MatchesCode ¶
type MatchesConstraint ¶
type MatchesConstraint string
type MatchesRoutine ¶
type MatchesRoutine string
type SearchOperatorConfigBase ¶
func NewSearchOperatorConfigBase ¶
func NewSearchOperatorConfigBase(field string, keys ...string) SearchOperatorConfigBase
func (SearchOperatorConfigBase) GetKeys ¶
func (c SearchOperatorConfigBase) GetKeys() []string
type SearchOperatorConfigBool ¶
type SearchOperatorConfigBool struct {
SearchOperatorConfigBase
}
func NewBoolOperator ¶
func NewBoolOperator(field string, keys ...string) SearchOperatorConfigBool
func (SearchOperatorConfigBool) Apply ¶
func (c SearchOperatorConfigBool) Apply(os, rem []operator.Operator, a *Accumulator, prefix string)
type SearchOperatorConfigStringLike ¶
type SearchOperatorConfigStringLike struct {
SearchOperatorConfigBase
}
func NewStringLikeOperator ¶
func NewStringLikeOperator(field string, keys ...string) SearchOperatorConfigStringLike
func (SearchOperatorConfigStringLike) Apply ¶
func (c SearchOperatorConfigStringLike) Apply(os, rem []operator.Operator, a *Accumulator, prefix string)
type SearchOperatorConfigUUID ¶
type SearchOperatorConfigUUID struct {
SearchOperatorConfigBase
}
func NewUUIDOperator ¶
func NewUUIDOperator(field string, keys ...string) SearchOperatorConfigUUID
func (SearchOperatorConfigUUID) Apply ¶
func (c SearchOperatorConfigUUID) Apply(os, rem []operator.Operator, a *Accumulator, prefix string)
type SimpleSort ¶
type SimpleSort string
func (SimpleSort) String ¶
func (s SimpleSort) String(key string) string
Click to show internal directories.
Click to hide internal directories.