pg: github.com/go-pg/pg/urlvalues Index | Files

package urlvalues

import "github.com/go-pg/pg/urlvalues"

Index

Package Files

decode.go pager.go url_filter.go values.go

func Decode Uses

func Decode(strct interface{}, values Values) error

Decode decodes url values into the struct.

func Filters Uses

func Filters(values Values) func(*orm.Query) (*orm.Query, error)

Filters is a shortcut for NewFilter(urlValues).Filters.

func Pagination Uses

func Pagination(values Values) func(*orm.Query) (*orm.Query, error)

Pagination is used with Query.Apply to set LIMIT and OFFSET from the URL values:

- ?limit=10 - sets q.Limit(10), max limit is 1000.
- ?page=5 - sets q.Offset((page - 1) * limit), max offset is 1000000.

type Filter Uses

type Filter struct {
    // contains filtered or unexported fields
}

URLFilter is used with Query.Apply to add WHERE clauses from the URL values:

- ?foo=bar - Where(`"foo" = 'bar'`)
- ?foo=hello&foo=world - Where(`"foo" IN ('hello','world')`)
- ?foo__neq=bar - Where(`"foo" != 'bar'`)
- ?foo__exclude=bar - Where(`"foo" != 'bar'`)
- ?foo__gt=42 - Where(`"foo" > 42`)
- ?foo__gte=42 - Where(`"foo" >= 42`)
- ?foo__lt=42 - Where(`"foo" < 42`)
- ?foo__lte=42 - Where(`"foo" <= 42`)
- ?foo__ieq=bar - Where(`"foo" ILIKE 'bar'`)
- ?foo__match=bar - Where(`"foo" SIMILAR TO 'bar'`)

func NewFilter Uses

func NewFilter(values Values) *Filter

func (*Filter) Allow Uses

func (f *Filter) Allow(filters ...string)

func (*Filter) Filters Uses

func (f *Filter) Filters(q *orm.Query) (*orm.Query, error)

func (*Filter) Values Uses

func (f *Filter) Values() Values

Values returns URL values.

type Pager Uses

type Pager struct {
    Limit  int
    Offset int

    // Default max limit is 1000.
    MaxLimit int
    // Default max offset is 1000000.
    MaxOffset int
    // contains filtered or unexported fields
}

func NewPager Uses

func NewPager(values Values) *Pager

func (*Pager) FromURLValues Uses

func (p *Pager) FromURLValues(values Values) error

func (*Pager) FromValues Uses

func (p *Pager) FromValues(values Values) error

func (*Pager) GetLimit Uses

func (p *Pager) GetLimit() int

func (*Pager) GetOffset Uses

func (p *Pager) GetOffset() int

func (*Pager) GetPage Uses

func (p *Pager) GetPage() int

func (*Pager) Pagination Uses

func (p *Pager) Pagination(q *orm.Query) (*orm.Query, error)

func (*Pager) SetPage Uses

func (p *Pager) SetPage(page int)

type Values Uses

type Values map[string][]string

func (Values) Bool Uses

func (v Values) Bool(name string) (bool, error)

func (Values) Duration Uses

func (v Values) Duration(name string) (time.Duration, error)

func (Values) Float64 Uses

func (v Values) Float64(name string) (float64, error)

func (Values) Has Uses

func (v Values) Has(name string) bool

func (Values) Int Uses

func (v Values) Int(name string) (int, error)

func (Values) Int64 Uses

func (v Values) Int64(name string) (int64, error)

func (Values) MaybeBool Uses

func (v Values) MaybeBool(name string) bool

func (Values) MaybeDuration Uses

func (v Values) MaybeDuration(name string) time.Duration

func (Values) MaybeFloat64 Uses

func (v Values) MaybeFloat64(name string) float64

func (Values) MaybeInt Uses

func (v Values) MaybeInt(name string) int

func (Values) MaybeInt64 Uses

func (v Values) MaybeInt64(name string) int64

func (Values) MaybeTime Uses

func (v Values) MaybeTime(name string) time.Time

func (Values) Pager Uses

func (v Values) Pager() *Pager

func (Values) SetDefault Uses

func (v Values) SetDefault(name string, values ...string)

func (Values) String Uses

func (v Values) String(name string) string

func (Values) Strings Uses

func (v Values) Strings(name string) []string

func (Values) Time Uses

func (v Values) Time(name string) (time.Time, error)

Package urlvalues imports 9 packages (graph) and is imported by 2 packages. Updated 2019-05-21. Refresh now. Tools for package owners.