filters

package
v0.9.5 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 2, 2020 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CommonBSONizerFunc

func CommonBSONizerFunc(b *BSONizer, s *query.Scope, field *mapping.StructField, fv *query.OperatorValues) (bson.D, error)

CommonBSONizerFunc is the BSONizerFunc used for multiple filter operators.

func EqualBSONFunc

func EqualBSONFunc(b *BSONizer, s *query.Scope, field *mapping.StructField, fv *query.OperatorValues) (results bson.D, err error)

EqualBSONFunc is the func that gets the filter bson.E for given scope and filter values.

func ExistsBSONizerFunc

func ExistsBSONizerFunc(b *BSONizer, s *query.Scope, field *mapping.StructField, fv *query.OperatorValues) (bson.D, error)

ExistsBSONizerFunc is the BSONizerFunc that checks if the given field exists in the given collection.

func InBSONizerFunc

func InBSONizerFunc(b *BSONizer, s *query.Scope, field *mapping.StructField, fv *query.OperatorValues) (bson.D, error)

InBSONizerFunc is the BSONizerFunc that handles $in and $notin operators.

func IsNullBSONizerFunc

func IsNullBSONizerFunc(b *BSONizer, s *query.Scope, field *mapping.StructField, fv *query.OperatorValues) (bson.D, error)

IsNullBSONizerFunc is the BSONizerFunc for the $isnull and $notnull operators.

func StringBSONizerFunc

func StringBSONizerFunc(b *BSONizer, s *query.Scope, field *mapping.StructField, fv *query.OperatorValues) (bson.D, error)

StringBSONizerFunc is the BSONizerFunc that handles string related filters operators.

Types

type BSONizer

type BSONizer struct {
	// contains filtered or unexported fields
}

BSONizer is the struct that creates and parses the bson.D for the given scope's query.

func NewBSONizer

func NewBSONizer(initialOperators ...*Operator) *BSONizer

NewBSONizer creates new BSONizer with the provided operators.

func (*BSONizer) ParseFilters

func (b *BSONizer) ParseFilters(s *query.Scope) (bson.D, error)

ParseFilters parses the query filters into bson.D format.

func (*BSONizer) RegisterOperator

func (b *BSONizer) RegisterOperator(o Operator) error

RegisterOperator registers the BSONizer Operator

type BSONizerFunc

type BSONizerFunc func(*BSONizer, *query.Scope, *mapping.StructField, *query.OperatorValues) (bson.D, error)

BSONizerFunc is the function that parses the scope's filter into bson.D struct.

type Operator

type Operator struct {
	O    *query.Operator
	Func BSONizerFunc
	Raw  string
}

Operator is the query.Operator wrapper that contains BSONizerFunc and a raw mongo string value.

func NewOperator

func NewOperator(o *query.Operator, bFunc BSONizerFunc, raw ...string) Operator

NewOperator creates new filters operator.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL