ormlist

package
v1.0.0-beta.1 Latest Latest
Warning

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

Go to latest
Published: Apr 18, 2023 License: Apache-2.0 Imports: 3 Imported by: 24

Documentation

Overview

Package ormlist defines options for listing items from ORM indexes.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CursorT

type CursorT []byte

CursorT defines a cursor type.

type Option

type Option = listinternal.Option

Option represents a list option.

func Cursor

func Cursor(cursor CursorT) Option

Cursor specifies a cursor after which to restart iteration. Cursor values are returned by iterators and in pagination results.

func DefaultLimit

func DefaultLimit(defaultLimit uint64) Option

DefaultLimit specifies a default limit for iteration. This option can be combined with Paginate to ensure that there is a default limit if none is specified in PageRequest.

func Filter

func Filter(filterFn func(message proto.Message) bool) Option

Filter returns an option which applies a filter function to each item and skips over it when the filter function returns false.

func Paginate

func Paginate(pageRequest *queryv1beta1.PageRequest) Option

Paginate paginates iterator output based on the provided page request. The Iterator.PageRequest value on the returned iterator will be non-nil after Iterator.Next() returns false when this option is provided.

Care should be taken when using Paginate together with Reverse and/or Cursor. In the case of combining Reverse and Paginate, if pageRequest.Reverse is true then iteration will proceed in the forward direction. This allows the default iteration direction for a query to be reverse with the option to switch this (to forward in this case) using PageRequest. If Cursor and Paginate are used together, whichever option is used first wins. If pageRequest is nil, this option will be a no-op so the caller does not need to do a nil check. This function defines no default limit, so if the caller does not define a limit, this will return all results. To specify a default limit use the DefaultLimit option.

func Reverse

func Reverse() Option

Reverse reverses the direction of iteration. If Reverse is provided twice, iteration will happen in the forward direction.

Jump to

Keyboard shortcuts

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