filtering

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jun 26, 2026 License: AGPL-3.0 Imports: 8 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const (
	// MaxQueryFilterLimit is the maximum value for list queries.
	MaxQueryFilterLimit = 250
	// DefaultQueryFilterLimit represents how many results we return in a response by default.
	DefaultQueryFilterLimit = 50

	// QueryKeySearchWithDatabase is the query param key to find search queries in requests.
	QueryKeySearchWithDatabase = "useDB"

	// QueryKeyLimit is the query param key to specify a limit in a query.
	QueryKeyLimit = "limit"
	// QueryKeyCursor is the query param key for specifying which cursor to use in a list query.
	QueryKeyCursor = "cursor"
	// QueryKeyCreatedBefore is the query param key for a creation time limit in a list query.
	QueryKeyCreatedBefore = "createdBefore"
	// QueryKeyCreatedAfter is the query param key for a creation time limit in a list query.
	QueryKeyCreatedAfter = "createdAfter"
	// QueryKeyUpdatedBefore is the query param key for an updated time limit in a list query.
	QueryKeyUpdatedBefore = "updatedBefore"
	// QueryKeyUpdatedAfter is the query param key for an updated time limit in a list query.
	QueryKeyUpdatedAfter = "updatedAfter"
	// QueryKeyIncludeArchived is the query param key for including archived results in a query.
	QueryKeyIncludeArchived = "includeArchived"
	// QueryKeySortBy is the query param key for sort order in a query.
	QueryKeySortBy = "sortBy"
)

Variables

View Source
var (
	// SortAscending is the pre-determined Ascending string for external use.
	SortAscending = new(sortAscendingString)
	// SortDescending is the pre-determined Descending string for external use.
	SortDescending = new(sortDescendingString)
)

Functions

This section is empty.

Types

type Pagination

type Pagination struct {
	AppliedQueryFilter *QueryFilter `json:"appliedQueryFilter"`
	Cursor             string       `json:"cursor"`
	PreviousCursor     string       `json:"previousCursor"`
	FilteredCount      uint64       `json:"filteredCount"`
	TotalCount         uint64       `json:"totalCount"`
	MaxResponseSize    uint8        `json:"maxResponseSize"`
	// contains filtered or unexported fields
}

Pagination represents a pagination request.

type QueryFilter

type QueryFilter struct {
	SortBy          *string    `json:"sortBy,omitempty"`
	CreatedAfter    *time.Time `json:"createdBefore,omitempty"`
	CreatedBefore   *time.Time `json:"createdAfter,omitempty"`
	UpdatedAfter    *time.Time `json:"updatedBefore,omitempty"`
	UpdatedBefore   *time.Time `json:"updatedAfter,omitempty"`
	MaxResponseSize *uint8     `json:"maxResponseSize,omitempty"`
	IncludeArchived *bool      `json:"includeArchived,omitempty"`
	Cursor          *string    `json:"cursor,omitempty"`
	// contains filtered or unexported fields
}

QueryFilter represents all the filters a User could apply to a list query.

func DefaultQueryFilter

func DefaultQueryFilter() *QueryFilter

DefaultQueryFilter builds the default query filter.

func ExtractQueryFilterFromRequest

func ExtractQueryFilterFromRequest(req *http.Request) *QueryFilter

ExtractQueryFilterFromRequest can extract a QueryFilter from a request.

func (*QueryFilter) AttachToLogger

func (qf *QueryFilter) AttachToLogger(logger logging.Logger) logging.Logger

AttachToLogger attaches a QueryFilter's values to a logging.Logger.

func (*QueryFilter) FromParams

func (qf *QueryFilter) FromParams(params url.Values)

FromParams overrides the core QueryFilter values with values retrieved from url.Params.

func (*QueryFilter) SetCursor

func (qf *QueryFilter) SetCursor(cursor *string)

SetCursor sets the current page with certain constraints.

func (*QueryFilter) ToPagination

func (qf *QueryFilter) ToPagination() Pagination

ToPagination returns a Pagination from a QueryFilter.

func (*QueryFilter) ToValues

func (qf *QueryFilter) ToValues() url.Values

ToValues returns a url.Values from a QueryFilter.

type QueryFilteredResult

type QueryFilteredResult[T any] struct {
	Data []*T `json:"data"`
	Pagination
	// contains filtered or unexported fields
}

func NewQueryFilteredResult

func NewQueryFilteredResult[T any](
	data []*T,
	filteredCount,
	totalCount uint64,
	idExtractor func(*T) string,
	filter *QueryFilter,
) *QueryFilteredResult[T]

NewQueryFilteredResult creates a new QueryFilteredResult.

Jump to

Keyboard shortcuts

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