collection

package
v1.7.3 Latest Latest
Warning

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

Go to latest
Published: Feb 14, 2018 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Format

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

Format collection as response-answer (Collection)

Types

type Collection

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

Collection response answer

type Filter

type Filter interface {
	Pager() Paginate
	Apply(*orm.Query) error
}

Filter interface

type Items

type Items = []interface{}

Items is formatted response of models

type ModelsFetcher

type ModelsFetcher = func(*orm.Query) (Items, error)

ModelsFetcher closure to fetch and format Items

type Options

type Options struct {
	Query   *orm.Query
	Fetcher ModelsFetcher
	Filter  Filter
}

Options to Format list-response

type Paginate

type Paginate struct {
	Offset int `query:"offset" form:"offset" json:"offset"`
	Limit  int `query:"limit" form:"limit" json:"limit"`
}

Paginate is part of filter structure

func (Paginate) Pager

func (p Paginate) Pager() Paginate

Pager returns Paginate-struct

Jump to

Keyboard shortcuts

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