Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( DefaultMinPageSize uint64 = 10 DefaultMaxPageSize uint64 = 100 )
Functions ¶
This section is empty.
Types ¶
type Filter ¶
type Filter struct {
Operation FilterOperation
Values []interface{}
}
type FilterOperation ¶
type FilterOperation int
const ( FilterOperationEqual FilterOperation = iota + 1 FilterOperationNotEqual FilterOperationGreater FilterOperationGreaterEqual FilterOperationLess FilterOperationLessEqual FilterOperationIn FilterOperationNotIn FilterOperationBetween )
type FilterParameter ¶
type FilterParameter string
FilterParameter defines a key for filtering paginated results. Custom filter parameters can be defined as needed by the application in service layer. Example value include:
- "status": To filter results by status (e.g, "active", "inactive").
- "user_id": To filter results by a specific user ID.
- "created_at": To filter results based on creation date.
type Paginated ¶
type Paginated struct {
Page uint64 `json:"page"`
PerPage uint64 `json:"per_page"`
Total uint64 `json:"total"`
Filters map[FilterParameter]Filter `json:"filters"`
SortColumn string `json:"sort_column"`
Descending bool `json:"descending"`
}
Paginated struct represents a paginated response that will be passed to the repository layer to retrieve data based on pagination settings, filters, sorting, etc.
type RequestBase ¶
type RequestBase struct {
CurrentPage uint64 `json:"current_page"`
PageSize uint64 `json:"page_size"`
Filters map[FilterParameter]Filter `json:"filters"`
SortColumn string `json:"sort_column"`
Descending bool `json:"descending"`
}
RequestBase the base structure for pagination requests from the client.
func (*RequestBase) BasicValidation ¶
func (r *RequestBase) BasicValidation() error
BasicValidation just ensure that the pagination request is well-formed. more complex validation should be dome in service layers based on the application's requirements.
Click to show internal directories.
Click to hide internal directories.