common

package
v0.0.0-...-34ec42c Latest Latest
Warning

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

Go to latest
Published: Jun 24, 2024 License: MIT Imports: 0 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type OrderBy

type OrderBy string

OrderBy is the field to order collections by

const (
	CREATED_AT OrderBy = "created_at"
	UPDATED_AT OrderBy = "updated_at"
	DELETED_AT OrderBy = "deleted_at"
)

type RequestParamOptions

type RequestParamOptions func(*RequestParams)

RequestParamOptions is a functional option that allows setting values to request parameters

func WithIncludeDeleted

func WithIncludeDeleted(hasDeleted bool) RequestParamOptions

WithIncludeDeleted sets whether to include deleted records

func WithOffset

func WithOffset(offset int) RequestParamOptions

WithOffset sets the offset of a pagination request

func WithOrderBy

func WithOrderBy(orderBy OrderBy) RequestParamOptions

WithSortOrder sets how to sort records

func WithRequestLimit

func WithRequestLimit(limit int) RequestParamOptions

WithRequestLimit sets the limit of a request

func WithSortOrder

func WithSortOrder(sortOrder SortOrder) RequestParamOptions

WithSortOrder sets how to sort records

type RequestParams

type RequestParams struct {
	// IncludedDeleted includes "softly" deleted records in the result of the query
	IncludeDeleted bool

	// Limit is the page size
	Limit int

	// Offset is the page number or cursor
	Offset int

	// OrderOption contains ordering options for the filter
	OrderOption RequestParamsOrderOption
}

RequestParams are parameters that can be passed when fetching records from a database

func NewRequestParams

func NewRequestParams(opts ...RequestParamOptions) RequestParams

NewRequestParams creates a new request params object with reasonable defaults set

type RequestParamsOrderOption

type RequestParamsOrderOption struct {
	// OrderBy is the field to order records by
	OrderBy OrderBy

	// SortOrder is the order to sort the records by
	SortOrder SortOrder
}

RequestParamsOrderOption contains filtering values to use for ordering

type SortOrder

type SortOrder string

SortOrder to use when sorting records

const (
	ASC  SortOrder = "ASC"
	DESC SortOrder = "DESC"
)

Jump to

Keyboard shortcuts

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