filter

package
v0.0.8 Latest Latest
Warning

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

Go to latest
Published: Nov 23, 2022 License: AGPL-3.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Generate

func Generate(s interface{}) (res bson.M, err error)

Generate generate mongo filter based on the input struct The struct may have sub-struct. Field used as filter must have tags with filtering options Eg: ```

type ExampleStruct struct {
	Toto  *int64    `mgo-filter:"toto,op:$eq,omitempty"`
	Titi  string   `mgo-filter:"titi,op:$gt"`
	Hello *[]string `mgo-filter:"hello,op:$in"`
}

``` The op is the filtering operation applied, When the omitempty option is set, the field will be ignored when nil or containing a zero value Field name should be in the form `fieldName` or `parentFieldName.fieldName` with any amount of subfield Note that using sub-structure won't change the resulting filter.

func RegisterStruct

func RegisterStruct(s interface{})

RegisterStruct register a struct in cache for quicker pagination generation when using the said struct

Types

This section is empty.

Jump to

Keyboard shortcuts

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