Documentation
¶
Index ¶
- Variables
- func SetMultiPair(selector *[]MultiFieldPair, column string, value []Value)
- func SetPair(selector *[]Pair, column string, value Value)
- func ValueFor[T FilterConstraints](fb *Filter, col string) (T, error)
- type Filter
- func (fb *Filter) Build() ([]string, []any, error)
- func (fb *Filter) BuildFunc(poff int, pchar string, pseq bool) ([]string, []any)
- func (fb *Filter) Hash() string
- func (fb *Filter) MakeKey() string
- func (fb *Filter) Valid() bool
- func (fb *Filter) Value(p Value) (any, error)
- func (fb *Filter) ValueFor(col string) (any, error)
- func (fb *Filter) Weld(sql string, args []any, paramoffset int) (string, []any, error)
- type FilterConstraints
- type MultiFieldPair
- type Null
- type Pair
- type Value
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrNoFilterSet error = errors.New("no filters set") ErrColumnNotFound error = errors.New("column not found") ErrDataNotSet error = errors.New("data was not set") ErrInvalidFieldName error = errors.New("invalid field name") ErrDataIsNotStruct error = errors.New("data is not struct") ErrDataAssertionMismatch error = errors.New("data assertion mismatch") ErrTypeReflectionInvalid error = errors.New("type reflection invalid") ErrPairTypeMustHaveMoreThanTwo error = errors.New("pair type must have more than two") )
Functions ¶
func SetMultiPair ¶
func SetMultiPair(selector *[]MultiFieldPair, column string, value []Value)
SetMultiPair sets a multi-pair array with the specified column and value
If the column does not exist, it will create one
Types ¶
type Filter ¶
type Filter struct {
Data any `json:"data,omitempty"`
Eq []Pair `json:"eq,omitempty"` // Equality pairs
Ne []Pair `json:"ne,omitempty"` // Not equality pairs
Lk []Pair `json:"lk,omitempty"` // Like pairs
Or [][]Pair `json:"or,omitempty"` // Or pairs
In []MultiFieldPair `json:"in,omitempty"` // In column pair.
NotIn []MultiFieldPair `json:"not_in,omitempty"` // Not In column pair
Between []MultiFieldPair `json:"between,omitempty"` // Between column pair
Placeholder string `json:"placeholder,omitempty"` // Parameter place holder
InSequence bool `json:"in_sequence,omitempty"` // Parameter place holders would be numbered in sequence
Offset int `json:"offset,omitempty"` // Sets the start of parameter number
AllowNoFilters bool `json:"allow_no_filters,omitempty"` // Allow no filter upon building
}
Filter - the filter struct
func (*Filter) Value ¶
Value gets the actual value of the struct field or the raw value that has been set
type FilterConstraints ¶
type FilterConstraints interface {
~int | ~int8 | ~int16 | ~int32 | ~int64 | ~uint | ~uint8 | ~uint16 |
~uint32 | ~uint64 | ~uintptr | ~float32 | ~float64 | ~string |
~[]int | ~[]int8 | ~[]int16 | ~[]int32 | ~[]int64 | ~[]uint | ~[]uint8 | ~[]uint16 |
~[]uint32 | ~[]uint64 | ~[]uintptr | ~[]float32 | ~[]float64 | ~[]string |
time.Time | ssd.Decimal | bool | []time.Time | []ssd.Decimal | []bool
}
type MultiFieldPair ¶
type MultiFieldPair struct {
Column string `json:"column,omitempty"` // Database table column
Value []Value `json:"value,omitempty"` // Struct field to get value
}
MultiFieldPair struct
func DataMultiPair ¶
func DataMultiPair(column string, fieldName ...string) MultiFieldPair
DataMultiPair simplifies data multi-pair. Pairs reads the Data field values via fieldName argument.
func NewMultiPairs ¶
func NewMultiPairs(pairs ...MultiFieldPair) []MultiFieldPair
NewMultiPairs simplify initialization of multi-field pairs
func RawMultiPair ¶
func RawMultiPair(column string, value ...any) MultiFieldPair
RawMultiPair simplifies raw multi-pair. Pairs reads the value argument raw.
type Pair ¶
type Pair struct {
Column string `json:"column,omitempty"` // Database table column
Value Value `json:"value,omitempty"` // Struct field to get value or the value itself
}
Pair struct
Click to show internal directories.
Click to hide internal directories.