types

package
v0.34.0 Latest Latest
Warning

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

Go to latest
Published: Aug 9, 2026 License: MIT Imports: 2 Imported by: 0

Documentation

Overview

Package types defines shared data types used across MicroJet, including the cursor-paginated result containers.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DecodePageToken

func DecodePageToken[T any](token *string) (*T, error)

func EncodePageToken

func EncodePageToken[T any](v T) (*string, error)

Types

type PagedResult

type PagedResult[T any] struct {
	Items         []T     `json:"items"`
	PageSize      int32   `json:"pageSize"`
	TotalCount    int64   `json:"totalCount"`
	NextPageToken *string `json:"nextPageToken"`
}

type PagedResultRequest

type PagedResultRequest struct {
	PageSize      int32   `json:"pageSize"`
	NextPageToken *string `json:"nextPageToken"`
	Page          *int32  `json:"page"`
}

PagedResultRequest carries pagination parameters for a list query.

It supports two mutually exclusive modes:

  • Cursor (default): leave Page nil and pass NextPageToken. Forward-only, TotalCount is not computed. Works with any backend.
  • Offset: set Page (1-based) for arbitrary page jumps. NextPageToken is ignored and TotalCount is populated. Only offset-capable backends (SQL via gormx) honor it; others reject an offset request.

func (*PagedResultRequest) ForceOffset added in v0.26.0

func (r *PagedResultRequest) ForceOffset() *PagedResultRequest

ForceOffset selects offset pagination when the caller didn't pick a mode, defaulting to the first page. Use it on SQL-backed listing endpoints that always want page-number pagination with a computed TotalCount, so a missing "page" query param falls back to page 1 instead of cursor mode.

Directories

Path Synopsis
Package money provides a currency-aware decimal money type with arithmetic that refuses to mix currencies and integer minor-unit conversion.
Package money provides a currency-aware decimal money type with arithmetic that refuses to mix currencies and integer minor-unit conversion.

Jump to

Keyboard shortcuts

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