Documentation ¶
Index ¶
- Constants
- func Field(name string) *field
- func IsField(v interface{}) bool
- type BinaryCriteria
- type Criteria
- type CriteriaVisitor
- type NotCriteria
- type Query
- func (q *Query) Collection() string
- func (q *Query) Criteria() Criteria
- func (q *Query) GetLimit() int
- func (q *Query) GetSkip() int
- func (q *Query) Limit(n int) *Query
- func (q *Query) MatchFunc(p func(doc *d.Document) bool) *Query
- func (q *Query) Skip(n int) *Query
- func (q *Query) Sort(opts ...SortOption) *Query
- func (q *Query) SortOptions() []SortOption
- func (q *Query) Where(c Criteria) *Query
- type SortOption
- type UnaryCriteria
Constants ¶
const ( ExistsOp = iota EqOp NeqOp GtOp GtEqOp LtOp LtEqOp LikeOp InOp ContainsOp FunctionOp )
const ( LogicalAnd = iota LogicalOr )
Variables ¶
This section is empty.
Functions ¶
Types ¶
type BinaryCriteria ¶
func (*BinaryCriteria) Accept ¶
func (c *BinaryCriteria) Accept(v CriteriaVisitor) interface{}
func (*BinaryCriteria) And ¶
func (c *BinaryCriteria) And(other Criteria) Criteria
func (*BinaryCriteria) Not ¶
func (c *BinaryCriteria) Not() Criteria
func (*BinaryCriteria) Or ¶
func (c *BinaryCriteria) Or(other Criteria) Criteria
type Criteria ¶
type Criteria interface { Satisfy(doc *d.Document) bool Accept(v CriteriaVisitor) interface{} Not() Criteria And(c Criteria) Criteria Or(c Criteria) Criteria }
Criteria represents a predicate for selecting documents. It follows a fluent API style so that you can easily chain together multiple criteria.
type CriteriaVisitor ¶
type CriteriaVisitor interface { VisitUnaryCriteria(c *UnaryCriteria) interface{} VisitNotCriteria(c *NotCriteria) interface{} VisitBinaryCriteria(c *BinaryCriteria) interface{} }
type NotCriteria ¶
type NotCriteria struct {
C Criteria
}
func (*NotCriteria) Accept ¶
func (c *NotCriteria) Accept(v CriteriaVisitor) interface{}
func (*NotCriteria) And ¶
func (c *NotCriteria) And(other Criteria) Criteria
func (*NotCriteria) Not ¶
func (c *NotCriteria) Not() Criteria
func (*NotCriteria) Or ¶
func (c *NotCriteria) Or(other Criteria) Criteria
type Query ¶
type Query struct {
// contains filtered or unexported fields
}
Query represents a generic query which is submitted to a specific collection.
func NewQuery ¶
NewQuery simply returns the collection with the supplied name. Use it to initialize a new query.
func (*Query) Collection ¶
func (*Query) Limit ¶
Limit sets the query q to consider at most n records. As a consequence, the FindAll() method will output at most n documents, and any integer m returned by Count() will satisfy the condition m <= n.
func (*Query) MatchFunc ¶
MatchFunc selects all the documents which satisfy the supplied predicate function.
func (*Query) Skip ¶
Skip sets the query so that the first n documents of the result set are discarded.
func (*Query) Sort ¶
func (q *Query) Sort(opts ...SortOption) *Query
Sort sets the query so that the returned documents are sorted according list of options.
func (*Query) SortOptions ¶
func (q *Query) SortOptions() []SortOption
type SortOption ¶
SortOption is used to specify sorting options to the Sort method. It consists of a field name and a sorting direction (1 for ascending and -1 for descending). Any other positive of negative value (except from 1 and -1) will be equivalent, respectively, to 1 or -1. A direction value of 0 (which is also the default value) is assumed to be ascending.
type UnaryCriteria ¶
func (*UnaryCriteria) Accept ¶
func (c *UnaryCriteria) Accept(v CriteriaVisitor) interface{}
func (*UnaryCriteria) And ¶
func (c *UnaryCriteria) And(other Criteria) Criteria
func (*UnaryCriteria) Not ¶
func (c *UnaryCriteria) Not() Criteria
func (*UnaryCriteria) Or ¶
func (c *UnaryCriteria) Or(other Criteria) Criteria