filters

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: May 30, 2019 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidOperatorMapped = errors.New("Invalid operator mapped for the BSONizerFunc")
)

Errors for the basic functions

View Source
var (
	ErrNoBSONOperator = errors.New("No BSON operator found")
)

Err`ors used in the filter bsonizers

Functions

func CommonBSONizerFunc

func CommonBSONizerFunc(b *BSONizer, s *query.Scope, field *mapping.StructField, fv *filters.OperatorValuePair) (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 *filters.OperatorValuePair) (bson.D, 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 *filters.OperatorValuePair) (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 *filters.OperatorValuePair) (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 *filters.OperatorValuePair) (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 *filters.OperatorValuePair) (bson.D, error)

StringBSONizerFunc is the function that checks if the given

Types

type BSONizer

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

BSONizer is the struct that creates the bson.D for the given scope's filters

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

func (*BSONizer) RegisterOperator

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

RegisterOperator registers the BSONizer Operator

type BSONizerFunc

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

type Operator

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

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

func NewOperator

func NewOperator(o *filters.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