scope

package
v0.0.0-...-e7367dc Latest Latest
Warning

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

Go to latest
Published: Oct 24, 2019 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

View Source
const (
	FilterKeyBrand = "brand"
	FilterKeyPrice = "price"
)
View Source
const (
	FilterOperatorEqual            = "eq"
	FilterOperatorGreaterThanEqual = "gte"
	FilterOperatorLowerThanEqual   = "lte"
)
View Source
const (
	PaginationOffsetDefault = 0
	PaginationLimitDefault  = 10
	RequestParameterOffset  = "offset"
	RequestParameterLimit   = "limit"
)
View Source
const (
	SortingFieldDefault = "price"
	SortingOrderDefault = "asc"
)
View Source
const RequestParameterQuery = "q"
View Source
const RequestParameterSorting = "sort"
View Source
const SearchTitle = "title"

Variables

View Source
var AvailableFilterKeys = []string{
	FilterKeyBrand,
	FilterKeyPrice,
}
View Source
var SearchFields = []string{SearchTitle}

Functions

func NewSearch

func NewSearch(r *http.Request) string

Types

type Filter

type Filter struct {
	Key      string
	Value    interface{}
	Operator string
}

type Filters

type Filters []*Filter

func NewFilters

func NewFilters(r *http.Request) Filters

type Pagination

type Pagination struct {
	Offset int
	Limit  int
}

func NewPagination

func NewPagination(r *http.Request) *Pagination

type Scope

type Scope struct {
	SearchQuery string
	Pagination  *Pagination
	Filters     Filters
	Sorting     *Sorting
}

func New

func New(sq string, p *Pagination, f Filters, s *Sorting) *Scope

type Sorting

type Sorting struct {
	Field string
	Order string
}

func NewSorting

func NewSorting(r *http.Request) *Sorting

Jump to

Keyboard shortcuts

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