paged

package
v0.0.0-...-5467f26 Latest Latest
Warning

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

Go to latest
Published: Nov 23, 2024 License: Apache-2.0 Imports: 7 Imported by: 1

Documentation

Overview

Package paged implements a helper for making paginated Datastore queries.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Query

func Query(ctx context.Context, lim int32, tok string, rsp Response, q *datastore.Query, cb any) error

Query executes a query to fetch the given page of results, invoking a callback function for each key or entity returned by the query. If the page isn't the last of the query, the given response will have its next page token set appropriately.

A non-positive limit means to fetch all results starting at the given page token in a single page. An empty page token means to start at the first page.

The callback must be a function of one argument, the type of which is either *datastore.Key (implies keys-only query) or a pointer to a struct to decode the returned entity into. The callback should return an error, which if not nil halts the query, and if the error is not datastore.Stop, causes this function to return an error as well. See datastore.Run for more information. No maximum page size is imposed, use datastore.Stop to enforce one.

Types

type Response

type Response interface {
	proto.Message
	// GetNextPageToken returns a token to use to fetch the next page of results.
	GetNextPageToken() string
}

Response is an interface implemented by ListResponses which support page tokens.

Jump to

Keyboard shortcuts

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