Documentation ¶
Overview ¶
Utility stuff that goes along with tmeta but is not core functionality.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Criteria ¶
type Criteria []Criterion
Criteria is a list of Criterion. If used as an Or (see Criterion struct definition) the various Criterions are ORed together, otherwise they are ANDed.
func (Criteria) CheckFieldNames ¶
CheckFieldNames returns an error if it encounters any field which is not in the list provided.
func (Criteria) ContainsMatch ¶
ContainsMatch calls ContainsMatch on each Criterion.
type Criterion ¶
type Criterion struct { Not bool `json:"not"` Field string `json:"field"` Op Op `json:"op"` Value interface{} `json:"value"` Or Criteria `json:"or"` }
Criterion is an individual expression that has a field, an op(erator) and a value. It also supports Not for inverting the criterion, and Or can be used to provide a list of other expressions to be ORed together.
func (Criterion) CheckFieldNames ¶
CheckFieldNames returns an error if it encounters any field which is not in the list provided.
func (Criterion) ContainsMatch ¶
ContainsMatch will look for any field in the given set which is "matched", meaning it's operator is any of the valid ones except LikeOp, which requires at least likePrefixLen characters at the start without a wildcard character ('%” or '_'). The idea is to restrict queries to specific (usually indexed) fields to avoid excessive database load.
type DBTime ¶
DBTime is a time value that should work with SQLite3, MySQL and Postgres. It supports subsecond precision, works with the database's underlying DATETIME field type (TEXT for SQLite3), won't get confused about time zones (stores in UTC), scans and JSON encodes/decodes properly.
func NewDBTimeFor ¶
NewDBTimeFor returns a DBTime corresponding to the time you provide.
type Op ¶
type Op string
Op is one of the supported SQL where operators used with Criteria and Criterion.
type OrderBy ¶
OrderBy corresponds to a single field in an ORDER BY SQL clause including it's direction (ascending by default).
func (OrderBy) CheckFieldNames ¶
CheckFieldNames returns true if the field for this OrderBy is not in the list provided.
func (*OrderBy) UnmarshalJSON ¶
UnmarshalJSON supports normal JSON unmarshaling plus a shorthand of just providing a string to mean the field name sorted ascending.
type OrderByList ¶
type OrderByList []OrderBy
OrderByList is a list of OrderBys.
func (OrderByList) CheckFieldNames ¶
func (ol OrderByList) CheckFieldNames(fields ...string) error
CheckFieldNames returns true if any of the fields for this OrderByList are not in the list provided.
func (*OrderByList) UnmarshalJSON ¶
func (ol *OrderByList) UnmarshalJSON(b []byte) error
UnmarshalJSON supports normal JSON unmarshaling plus a shorthand of just providing either a single object instead of an array, or a string to mean the field name sorted ascending.