Documentation ¶
Overview ¶
Package tql Torpedo Query Language
Index ¶
- Constants
- Variables
- func CursorToDocument(q *Query, filter bson.D) (cursorFilter bson.D, limit int64, sortD bson.D)
- func CursorToSQL(q *Query, filter string) (sqlWhere string, sqlLimit int64, sqlOrder string)
- func FieldValue(qro interface{}, field string) interface{}
- func MapToMongoDBFilter(q *Query, metadata map[string]string) (bson.D, error)
- func MapToSQLFilter(q *Query, metadata map[string]string) (string, map[string]interface{}, error)
- func ToMongoDBMetadata(dmo interface{}, skip ...string) map[string]string
- func ToSortDocument(items []SortItem) bson.D
- func ToSortSQL(items []SortItem) string
- type Cursor
- func CursorFromQuery(q *Query) *Cursor
- func NewPaginationCursor(rawCursor string) (*Cursor, error)
- func NewPaginationCursorFrom(pivot string, sort CursorOrderType, sortField string, sortVal interface{}, ...) *Cursor
- func NewPaginationCursorFromBeginning(sort string) *Cursor
- func NewPaginationCursorFromPivot(pivot string, sort CursorOrderType) *Cursor
- type CursorOrderType
- type ExportableCursor
- type ExportableCursorSort
- type Filter
- type FilterItem
- type Pagination
- type PaginationCursor
- type PaginationCursorMeta
- type PaginationMeta
- type PaginationOffset
- type Query
- func (q *Query) CursorPaginationSort() *SortItem
- func (q *Query) CursorType() string
- func (q *Query) HasCursorMeta() bool
- func (q *Query) HasPagination() bool
- func (q *Query) HasSort() bool
- func (q *Query) HasValidPagination() bool
- func (q *Query) IsCursorPagination() bool
- func (q *Query) IsCursorPaginationNext() bool
- func (q *Query) IsCursorPaginationPrev() bool
- func (q *Query) IsOffsetPagination() bool
- func (q *Query) IsPaginationCursorEmpty() bool
- func (q *Query) OffsetPaginationSort() []SortItem
- func (q *Query) PaginationCursor() string
- func (q *Query) PaginationCursorOrder() string
- func (q *Query) PaginationItems() int64
- func (q *Query) PaginationOffset() int64
- func (q *Query) PaginationOffsetPage() int64
- func (q *Query) PaginationRAWItems() int64
- func (q *Query) Validate(fields entity.FieldMap) error
- type Result
- type ResultMeta
- type SortItem
Constants ¶
View Source
const ( FilterTypeAny = "any" FilterTypeAll = "all" OpNEQ = "!=" OpEQ = "==" OpGT = ">" OpGTE = ">=" OpLT = "<" OpLTE = "<=" OpBTLimits = "[n]" OpBTNoLimits = "(n)" OpBTLeftLimit = "[n)" OpBTRightLimit = "(n]" OpIN = "[?]" OpPrefix = "s.." OpSuffix = "..s" OpContains = ".s." )
View Source
const ( CursorNext = "next" CursorPrev = "prev" CursorAscStr = "asc" CursorDescStr = "desc" CursorDesc CursorOrderType CursorAsc )
View Source
const ( PageTypeOffset = "offset" PageTypeCursor = "cursor" PaginationCursortOrderASC = "asc" PaginationCursorOrderDESC = "desc" PaginationCursorEmpty = "" )
Variables ¶
View Source
var ( // ErrTQLNotSupported Torpedo Query Language is not supported by this repository ErrTQLNotSupported = errors.New("Torpedo Query Language is not supported by this repository") // ErrEmptyFilter filter cannot be empty ErrEmptyFilter = errors.New("filter cannot be empty") // ErrInvalidOperator the given operator is invalid ErrInvalidOperator = errors.New("the given operator is invalid") // ErrInvalidValue the given value is invalid ErrInvalidValue = errors.New("the given value is invalid") // ErrInvalidValueBTLen the given value must be a list of 2 elements (left and right limits) ErrInvalidValueBTLen = errors.New("the given value must be a list of 2 elements (left and right limits)") // ErrOperationNotSupported the given operation is not supported for the given field ErrOperationNotSupported = errors.New("the given operation is not supported for the given field") // ErrInvalidFieldName the given field name is invalid ErrInvalidFieldName = errors.New("the given field name is invalid") // ErrInvalidFieldNameAtProjection the given field name into projection list is invalid ErrInvalidFieldNameAtProjection = errors.New("the given field name into projection list is invalid") // ErrInvalidFieldNameAtSort the given field name into sort list is invalid ErrInvalidFieldNameAtSort = errors.New("the given field name into sort list is invalid") // ErrQueryResultObjectBuild something happens building a QRO from the entity ErrQueryResultObjectBuild = errors.New("something happens building a QRO from the entity") // ErrInvalidPaginationType the pagination must be 'cursor' or 'offset' ErrInvalidPaginationType = errors.New("the pagination must be 'cursor' or 'offset'") // ErrInvalidSortFieldNotProjectionMember sort field must be a member of the projection field list ErrInvalidSortFieldNotProjectionMember = errors.New("sort field must be a member of the projection field list") )
Functions ¶
func CursorToDocument ¶
func CursorToSQL ¶
func FieldValue ¶ added in v0.3.0
func FieldValue(qro interface{}, field string) interface{}
func MapToMongoDBFilter ¶
func MapToSQLFilter ¶
func ToMongoDBMetadata ¶ added in v0.3.0
func ToSortDocument ¶
Types ¶
type Cursor ¶
type Cursor struct {
// contains filtered or unexported fields
}
func CursorFromQuery ¶
func NewPaginationCursor ¶
func NewPaginationCursorFrom ¶
func NewPaginationCursorFrom(pivot string, sort CursorOrderType, sortField string, sortVal interface{}, sortType string) *Cursor
func NewPaginationCursorFromPivot ¶
func NewPaginationCursorFromPivot(pivot string, sort CursorOrderType) *Cursor
func (*Cursor) Order ¶
func (c *Cursor) Order() CursorOrderType
type CursorOrderType ¶
type CursorOrderType int8
func PaginationCursorOrder ¶
func PaginationCursorOrder(sort string) CursorOrderType
type ExportableCursor ¶
type ExportableCursor struct { Pivot string `json:"pivot"` PivotSort string `json:"pivotSort"` Sort *ExportableCursorSort `json:"sort,omitempty"` }
func NewExportableCursorFrom ¶
func NewExportableCursorFrom(cursor string) (*ExportableCursor, error)
func (*ExportableCursor) String ¶
func (ec *ExportableCursor) String() string
type ExportableCursorSort ¶
type Filter ¶
type Filter struct { Type_ *string `json:"type"` Fields []FilterItem `json:"fields"` }
type FilterItem ¶
type Pagination ¶
type Pagination struct { Items *int64 `json:"items,omitempty"` Cursor *PaginationCursor `json:"cursor,omitempty"` Offset *PaginationOffset `json:"offset,omitempty"` }
type PaginationCursor ¶
type PaginationCursor struct { Meta *PaginationCursorMeta `json:"meta,omitempty"` Mark *string `json:"nextToken,omitempty"` }
type PaginationCursorMeta ¶
type PaginationMeta ¶
type PaginationOffset ¶
type Query ¶
type Query struct { Filter *Filter `json:"filter"` Projection []string `json:"projection,omitempty"` Pagination *Pagination `json:"pagination,omitempty"` }
func (*Query) CursorPaginationSort ¶
func (*Query) CursorType ¶
func (*Query) HasCursorMeta ¶
func (*Query) HasPagination ¶
func (*Query) HasValidPagination ¶
func (*Query) IsCursorPagination ¶
func (*Query) IsCursorPaginationNext ¶
func (*Query) IsCursorPaginationPrev ¶
func (*Query) IsOffsetPagination ¶
func (*Query) IsPaginationCursorEmpty ¶
func (*Query) OffsetPaginationSort ¶
func (*Query) PaginationCursor ¶
func (*Query) PaginationCursorOrder ¶
func (*Query) PaginationItems ¶
func (*Query) PaginationOffset ¶
func (*Query) PaginationOffsetPage ¶
func (*Query) PaginationRAWItems ¶
type Result ¶
type Result struct { Meta ResultMeta `json:"meta"` Data []interface{} `json:"data"` }
type ResultMeta ¶
type ResultMeta struct { Count int64 `json:"count"` //Prev interface{} `json:"prev"` Next interface{} `json:"next"` }
Click to show internal directories.
Click to hide internal directories.