> For the complete documentation index, see [llms.txt](https://docs.overdare.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.overdare.com/development/api-reference/classes/datastorepages.md).

# DataStorePages

DataStorePages : `Pages`

## Overview

A Pages object that lets you iterate through the entries stored in an OrderedDataStore in sorted order, divided into pages.

It can only be retrieved through the OrderedDataStore:GetSortedAsync() method and cannot be created with Instance.new(). It can only be used in a server environment.

Calling GetCurrentPage() returns the entries on the current page as an array, and each entry is a table with the following fields.

* **key** : The key of the entry. It is always returned as a string even if it was saved as a number, so convert it with tonumber() if needed.
* **value** : The integer value stored in the entry.

If no entries match, GetCurrentPage() returns an empty table rather than nil, and IsFinished is true in that case.

If IsFinished is false, you can load the next page with AdvanceToNextPageAsync(), and IsFinished becomes true once the current page is the last one.

**Important Notes**

* Calling AdvanceToNextPageAsync() on the last page raises an error. The current page and IsFinished remain unchanged.
* If you call AdvanceToNextPageAsync() again on the same DataStorePages while a call is in progress, the later call fails immediately and the current page remains unchanged. Once the preceding call ends, whether by success, failure, or timeout, you can call it again.
* Different DataStorePages objects can advance pages at the same time without affecting each other.
* AdvanceToNextPageAsync() uses the same request limit as GetSortedAsync, so it can fail immediately when the limit is exceeded. Wrapping the call in pcall is recommended.
* If entries are added to or deleted from the store while you page through it, those changes are reflected in the next page, so the same entry can appear twice or be missed.

## Properties

## Methods

## Events

## See also

{% content-ref url="/pages/0HdSSTnGaZLH8ptzpz2F" %}
[OrderedDataStore](/development/api-reference/classes/ordereddatastore.md)
{% endcontent-ref %}

{% content-ref url="/pages/faztiZVM1KMYewnGlEy3" %}
[Custom Leaderboard](/manual/script-manual/advanced-gameplay-systems/ordereddatastore.md)
{% endcontent-ref %}
