collection

package
v1.18.0 Latest Latest
Warning

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

Go to latest
Published: Aug 27, 2020 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultItemsLimit = 50

DefaultItemsLimit per page limit

View Source
var SeparatorOrder = ","

SeparatorOrder

Functions

func Response added in v1.7.4

func Response(ctx web.Context, opts Options) error

Response collection as response-answer (Collection)

if you do not want to use opts.Query then see https://gist.github.com/jenchik/05a6a1bc80e7199203b8fa122cdaf922

Types

type Collection

type Collection struct {
	Total int   `json:"total"`
	Items Items `json:"items"`
}

Collection response answer

type Fetcher added in v1.7.4

type Fetcher = func(*Options) (Items, error)

Fetcher closure to fetch and format Items

type Form added in v1.7.4

type Form struct {
	Order  string      `query:"order" form:"order" json:"order"`
	Offset json.Number `query:"offset" form:"offset" json:"offset" validate:"omitempty,numeric"`
	Limit  json.Number `query:"limit" form:"limit" json:"limit" validate:"omitempty,numeric"`
}

Form is part of filter structure

func (*Form) ApplyFilter added in v1.7.4

func (*Form) ApplyFilter(*Options) (err error)

ApplyFilter your filters to a Query

func (*Form) ApplyPager added in v1.7.4

func (f *Form) ApplyPager(opts *Options) (err error)

ApplyPager

func (*Form) ApplySorter added in v1.7.4

func (f *Form) ApplySorter(opts *Options) error

ApplySorter your sorter to a Query

type Former added in v1.7.4

type Former interface {
	ApplyFilter(*Options) error
	ApplyPager(*Options) error
	ApplySorter(*Options) error
}

Former interface

type Items

type Items = []interface{}

Items is formatted response of models

type Options

type Options struct {
	Query   *orm.Query
	Fetcher Fetcher
	Former  Former
}

Options to Format list-response

Jump to

Keyboard shortcuts

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