Package paged implements a helper for making paginated Datastore queries.



This section is empty.


This section is empty.


func Query

func Query(c context.Context, lim int32, tok string, rsp Response, q *datastore.Query, cb interface{}) 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.


type Response

type Response interface {
	// 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.

Source Files