const ( OpAnd = Operator("$and") OpOr = Operator("$or") OpNot = Operator("$not") OpNor = Operator("$nor") OpAllMatch = Operator("$allMatch") OpKeyMapMatch = Operator("$keyMapMatch") )
const ( OpLessThan = Operator("$lt") OpLessThanOrEqual = Operator("$lte") OpEqual = Operator("$eq") OpNotEqual = Operator("$ne") OpGreaterThan = Operator("$gt") OpGreaterThanOrEqual = Operator("$gte") OpExists = Operator("$exists") OpType = Operator("$type") OpIn = Operator("$in") OpNotIn = Operator("$nin") OpSize = Operator("$size") OpMod = Operator("$mod") OpRegex = Operator("$regex") OpAll = Operator("$all") OpElemMatch = Operator("$elemMatch") )
func Match(sel Node, doc interface{}) bool
Match returns true if the selector matches the input document. doc is expected to be the result of unmarshaling JSON to an empty interface. An invalid document will cause Match to panic.
func SplitKeys(field string) []string
SplitKeys splits a field into its component keys. For example, "foo.bar" is split into `["foo", "bar"]`. Escaped dots are not treated as separators, so `"foo\\.bar"` becomes `["foo.bar"]`.
Node represents a node in the Mango Selector.
type Node interface { Op() Operator Value() interface{} String() string Match(interface{}) bool }
func Parse(input []byte) (Node, error)
Parse parses s into a Mango Selector tree.
Operator represents a Mango operator.
type Operator string
Selector represents a Mango Selector tree.
type Selector struct {
// contains filtered or unexported fields
}
func (s *Selector) Match(doc interface{}) bool
Match returns true if doc matches the selector.
func (s *Selector) UnmarshalJSON(data []byte) error
UnmarshalJSON parses the JSON-encoded data and stores the result in s.