Skip to content

Commit

Permalink
[DOCS-2634] Document Client.paginate() (#255)
Browse files Browse the repository at this point in the history
Co-authored-by: Cleve Stuart <90649124+cleve-fauna@users.noreply.github.com>
  • Loading branch information
jrodewig and cleve-fauna authored Apr 3, 2024
1 parent c351e20 commit 36e264f
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ See the [Fauna Documentation](https://docs.fauna.com/fauna/current/) for additio
- [Typescript support](#typescript-support)
- [Query options](#query-options)
- [Query statistics](#query-statistics)
- [Pagination](#pagination)
- [Event Streaming (beta)](#event-streaming-beta)
- [Client configuration](#client-configuration)
- [Environment variables](#environment-variables)
Expand Down Expand Up @@ -276,6 +277,41 @@ Example output:
}
```

## Pagination

Use the `Client.paginate()` method to iterate sets that contain more than one page of results.

`Client.paginate()` accepts the same [query options](#query-options) as
`Client.query()`.

Change the default items per page using FQL's `<set>.pageSize()` method.

```typescript
import { fql, Client, type SetIterator, type QueryValue } from "fauna";

const client = new Client();

// Adjust `pageSize()` size as needed.
const query = fql`
Product
.byName("limes")
.pageSize(60) { description }`;

const options = {
query_timeout_ms: 60_000,
};

const pages: SetIterator<QueryValue> = client.paginate(query, options);

for await (const products of pages) {
for (const product of products) {
console.log(product)
}
}

client.close();
```


## Event Streaming (beta)

Expand Down

0 comments on commit 36e264f

Please sign in to comment.