paging

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: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GeneratePagination

func GeneratePagination(s interface{}) (res options.FindOptions, err error)

GeneratePagination generate mongo option for pagination based on the input struct The struct should have root-level field with tags indicating the usage of the field and default value when applicable Eg: ```

type SimplemPagingStruct struct {
	Limit  *int64  `mgo-paging:"limit,default: 10"`
	Offset *int64  `mgo-paging:"offset"`
	Sort   *string `mgo-paging:"sort,default: _id"`
}

``` The `default` opt is the default value, used when the field is a nil pointer. The `limit`, `offset` and `sort` value define what the field is used for. The sort field value should contain the key used for sorting. You can add a `-` as prefix to revert the sorting order. Eg: `-_id`, `_id`, `myField`, `-myField`

func RegisterStruct

func RegisterStruct(s interface{}) error

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

Types

type StdPaging

type StdPaging struct {
	Limit  *int64  `mgo-paging:"limit,default: 10"`
	Offset *int64  `mgo-paging:"offset"`
	Sort   *string `mgo-paging:"sort,default: _id"`
}

StdPaging contains standard pagination fields

Jump to

Keyboard shortcuts

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