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 ¶
Click to show internal directories.
Click to hide internal directories.