pageSize()
Description
The pageSize()
method sets the maximum elements per page in paginated results.
If a subsequent page is available, the result includes an after
cursor. To
iterate through paginated results, pass the after
cursor to
Set.paginate()
.
Method chaining
pageSize()
should typically be the last method call in an FQL statement.
pageSize()
only affects the rendering of a set, not subsequent operations.
Methods chained to pageSize()
access the entire calling set, not a page of
results.
Differences with paginate()
Unlike pageSize()
,
paginate()
:
If you need to access an after
cursor or paginated results within an FQL
query, use paginate()
. Otherwise, you should use pageSize()
.
Return value
Type | Description | ||
---|---|---|---|
Set that includes the following field:
|
Examples
// Calls `pageSize()` with a size of `2`.
Product.all().pageSize(2)
{
// The returned set contains two elements or fewer.
data: [
{
id: "393605620096303168",
coll: Product,
ts: Time("2099-03-28T12:53:40.750Z"),
name: "limes",
...
},
{
id: "393605620102594624",
coll: Product,
ts: Time("2099-03-28T12:53:40.750Z"),
name: "cilantro",
...
}
],
after: "hdaExad..."
}
Is this article helpful?
Tell Fauna how the article can be improved:
Visit Fauna's forums
or email docs@fauna.com
Thank you for your feedback!