QueryResult
Defined in: src/query/queryResult.ts:21
One page of query results.
A page is immutable: next returns the following page rather than mutating this one, so a page that has been read stays readable.
Example
Section titled “Example”let page = await client.select({ key: true }).where(eq("category", "docs")).limit(100).fetch()while (page.hasNextPage()) { page = await page.next()}Type Parameters
Section titled “Type Parameters”TEntity
Section titled “TEntity”TEntity = Entity
The shape of each entity, inferred from the selection by client.select().
Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new QueryResult<
TEntity>(entities,blockNumber,cursor,fetchPage):QueryResult<TEntity>
Defined in: src/query/queryResult.ts:36
Parameters
Section titled “Parameters”entities
Section titled “entities”readonly TEntity[]
blockNumber
Section titled “blockNumber”bigint
cursor
Section titled “cursor”string | undefined
fetchPage
Section titled “fetchPage”FetchPage<TEntity>
Returns
Section titled “Returns”QueryResult<TEntity>
Properties
Section titled “Properties”blockNumber
Section titled “blockNumber”
readonlyblockNumber:bigint
Defined in: src/query/queryResult.ts:30
The block this page was read at.
Every page of one walk reads the same block — the cursor is bound to it — so results cannot shift under a paginating reader.
cursor
Section titled “cursor”
readonlycursor:string|undefined
Defined in: src/query/queryResult.ts:32
The cursor for the next page, or undefined when this was the last one.
entities
Section titled “entities”
readonlyentities: readonlyTEntity[]
Defined in: src/query/queryResult.ts:23
The entities on this page.
Methods
Section titled “Methods”hasNextPage()
Section titled “hasNextPage()”hasNextPage():
boolean
Defined in: src/query/queryResult.ts:54
Whether another page follows.
The node omits the cursor once nothing remains, so this is an answer rather than the guess a short final page would be — a full last page is reported correctly.
Returns
Section titled “Returns”boolean
next()
Section titled “next()”next():
Promise<QueryResult<TEntity>>
Defined in: src/query/queryResult.ts:67
Fetches the next page.
Returns
Section titled “Returns”Promise<QueryResult<TEntity>>
Throws
Section titled “Throws”If this was the last page — check hasNextPage first.
Throws
Section titled “Throws”If the node rejects the request; kind === "cursor" means the cursor
expired and the walk has to start again.