Documentation ¶
Index ¶
Constants ¶
const ( // PageTokenDefaultEncryptionKey the default secret key for PageToken encryption. PageTokenDefaultEncryptionKey = "Some_Page_Token_Key_1927_!@#$*~<" // 32 bytes, therefore, AES 256-bit )
Variables ¶
var ( // ErrInvalidPageToken the token cannot be built. ErrInvalidPageToken = errors.New("invalid page token") )
Functions ¶
This section is empty.
Types ¶
type ComparisonOperator ¶
type ComparisonOperator uint16
ComparisonOperator an operator for comparisons.
const ( OperatorEquals ComparisonOperator = iota + 1 OperatorGreaterThan OperatorGreaterThanEquals OperatorLessThan OperatorLessThanEquals OperatorBetween OperatorNotBetween OperatorNotEquals OperatorIn OperatorNotIn OperatorLike OperatorNotLike OperatorExists OperatorNotExists OperatorIsNull OperatorIsNotNull )
type LogicalOperator ¶
type LogicalOperator uint8
LogicalOperator an operator for logical operations (concatenations, e.g. AND, OR).
const ( LogicalOperatorAnd LogicalOperator = iota + 1 LogicalOperatorOr )
type OrderType ¶
type OrderType uint8
OrderType the ordering type for a persistence operation (DESC, ASC).
type Page ¶
type Page[T any] struct { PreviousPageToken PageToken `json:"previous_page_token"` NextPageToken PageToken `json:"next_page_token"` TotalItems int `json:"total_items"` Items []T `json:"items"` }
Page a chunk of items from a dataset with metadata used to fetch more data.
type PageToken ¶
type PageToken []byte
PageToken Tokens are first encrypted so anybody is able to see internal system implementation details. Then, the token is encoded in hex format, so it can be transferred through network protocols, and thus, systems.
The token is able to use different pagination mechanism.
The nomenclature proposal would be this: QUERY_TYPE#NEXT_QUERY Nomenclature examples:
- OFFSET#100
- KEY_SET#name>'Foo'
- CURSOR#abc-foo
func NewPageToken ¶
func NewPageToken(encryptor encryption.Encryptor, queryType PaginationType, value string) (PageToken, error)
NewPageToken allocates a new PageToken instance.
func (PageToken) MarshalText ¶
MarshalText encodes the receiver into UTF-8-encoded text and returns the result.
type PaginationType ¶
type PaginationType string
PaginationType the type of pagination for a
const ( PaginationTypeOffset PaginationType = "OFFSET" PaginationTypeKeySet PaginationType = "KEY_SET" PaginationTypeCursor PaginationType = "CURSOR" )