query

package
v2.0.10 Latest Latest
Warning

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

Go to latest
Published: Dec 6, 2020 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Push

func Push(query *Query, filter interface{}) (ok bool, err error)

Push applies single filter to a query

func WithContext added in v2.0.8

func WithContext(ctx context.Context, q *Query) (withQuery context.Context)

WithContext function creates the new context with request data

Types

type Callback added in v2.0.8

type Callback func(ctx context.Context, iter interface{}) (err error)

type Callbacks added in v2.0.8

type Callbacks []Callback

func (Callbacks) Invoke added in v2.0.8

func (c Callbacks) Invoke(ctx context.Context, iter interface{}) (err error)

Invoke callbacks sequence

type Limit

type Limit int64

Limit is a simple implementation of the Limiter filter

func (Limit) Limit

func (l Limit) Limit() (limit *int64)

Limit returns a limit

type Limiter

type Limiter interface {
	Limit() (limit *int64)
}

Limiter is a filter to limit the result

type OnClose added in v2.0.8

type OnClose Callback

type OnDecode added in v2.0.7

type OnDecode Callback

type Preload

type Preload []string

Preload is a simple implementation of the Skipper filter

func (Preload) Preload

func (l Preload) Preload() (preloads []string)

Preload returns a preload list

type Preloader

type Preloader interface {
	Preload() (preloads []string)
}

Preloader is a filter to skip the result

type Query

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

Query is an enchanched primitive.M map

func Compose

func Compose(filters ...interface{}) (query *Query, err error)

Compose is a function to compose filters into a single query

func GetFromContext added in v2.0.8

func GetFromContext(ctx context.Context) (q *Query, ok bool)

GetFromContext function extracts the request data from context

func (*Query) And

func (q *Query) And(elem primitive.M) (query *Query)

And function pushes the elem query to the $and array of the query

func (*Query) Empty

func (q *Query) Empty() (isEmpty bool)

Empty checks the query for any content

func (*Query) Limiter

func (q *Query) Limiter() (limit *int64)

Limiter returns limiter value or nil

func (*Query) M

func (q *Query) M() (m primitive.M)

M returns underlying query map

func (*Query) OnClose added in v2.0.8

func (q *Query) OnClose() (callbacks Callbacks)

OnClose callback is called after the mongox ends a loading procedure

func (*Query) OnCreate added in v2.0.10

func (q *Query) OnCreate() (callbacks Callbacks)

OnCreate callback is called if the mongox creates a new document instance during loading

func (*Query) OnDecode added in v2.0.7

func (q *Query) OnDecode() (callbacks Callbacks)

OnDecode callback is called after the mongo decode function

func (*Query) Preloader

func (q *Query) Preloader() (preloads []string, ok bool)

Preloader is a preloader list for a query

func (*Query) Skipper

func (q *Query) Skipper() (skip *int64)

Skipper is a skipper for a query

func (*Query) Sorter

func (q *Query) Sorter() (sort interface{})

Sorter is a sort rule for a query

func (*Query) Updater added in v2.0.9

func (q *Query) Updater() (update primitive.M, err error)

Updater is an update command for a query

type Skip

type Skip int64

Skip is a simple implementation of the Skipper filter

func (Skip) Skip

func (l Skip) Skip() (skip *int64)

Skip returns a skip number

type Skipper

type Skipper interface {
	Skip() (skip *int64)
}

Skipper is a filter to skip the result

type Sort

type Sort primitive.M

Sort is a simple implementations of the Sorter filter

func (Sort) Sort

func (f Sort) Sort() (sort primitive.M)

Sort returns a slice of fields which have to be sorted

type Sorter

type Sorter interface {
	Sort() (sort primitive.M)
}

Sorter is a filter to sort the data before query

type Update added in v2.0.9

type Update primitive.M

Update is a simple implementations of the Updater filter

func (Update) Update added in v2.0.9

func (u Update) Update() (update primitive.M)

Update returns an update command

type Updater added in v2.0.9

type Updater interface {
	Update() (update primitive.M)
}

Updater is a filter to update the data

type Validator added in v2.0.9

type Validator interface {
	Validate() (err error)
}

Validator is a filter to validate the filter

Jump to

Keyboard shortcuts

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