summarize pagination

i'm using summarize to get unique values for a text column from my table. i've pageSize set to 10. with getPaginated i use the meta in the object returned to implement cursor based pagination. with summarize i don't have the meta in the object returned. how can i go about implementing pagination with summarize?
8 Replies
cmck
cmck7d ago
The lack of meta in this context is a limitation of summarize which can be paginated https://xata.io/docs/sdk/summarize#page but cannot be used with cursor-based pagination.
Summarize
Perform calculations and get insights on a set of records using the Xata SDK
mrcentigrade
mrcentigradeOP7d ago
thank you. i got it. i'm struggling to get the nextPage though. do i use offset for this?
const records = await xata.db.sales.summarize({
pagination: {
size: 50 // return up to 50 results
offset: 100
}
});
const records = await xata.db.sales.summarize({
pagination: {
size: 50 // return up to 50 results
offset: 100
}
});
i'm unable to find any example.
cmck
cmck6d ago
Unfortunately, at the moment, summarize only supports size for pagination. It does not support cursor or offset-based pagination (nextPage).
mrcentigrade
mrcentigradeOP6d ago
oh ok. so at the moment there's no way for me to view the next page of results? 😦
cmck
cmck6d ago
As it stands, not when using summarize but let me see if I can find a workaround.
mrcentigrade
mrcentigradeOP6d ago
thank you. that will be really helpful. i looked at the type signatures for summarize and aggregate api responses and they both don't include meta. this makes me apprehensive in using xata for business intelligence dashboard use cases. these usually feature aggregated results and i get definitely foresee need to paginate these api results. my current use-case is more transactional so i can live with maybe pre-populating the records and use getPaginated api on it. i hope there is some way to support getPaginated to these apis like it's done for the query api. please let me know if i can put a feature request or comment on one if there is one already. 🫡
cmck
cmck6d ago
Thanks for the detailed feedback, I'll pass it on to the team. You can also submit a feature request via https://feedback.xata.io/feature-requests I've not been able to find a means to paginate aggregate or summarize results, unfortunately, but it is something we will consider moving forward.
Feature Requests | Xata
Give feedback to the Xata team so we can make more informed product decisions. Powered by Canny.
mrcentigrade
mrcentigradeOP6d ago
done 👍 thank you.
Want results from more Discord servers?
Add your server