Setup of paginated query for firestore

I am trying to setup paginated queries towards a firestore repo. My problem is with setting the StartAt value, systems always come back with a circular reference error ...

current config:

Screen Shot 2021-12-10 at 10.39.22

Hey there @CarosatiG and welcome to the community! Sorry for the delay here :slight_smile:

You're getting this error because you're trying to reference the query itself, which is circular (as the message states). I'm assuming you've already look at our docs or server side table pagination? Working with tables

The magic is in offloading some of this data storing to the table component itself. You'd use your JS for finding the last ID in the table, not the query itself, like so:

Facing the same issue here, setting the next page cursor is only part of the problem as the query doesn't even seem to load the first page properly as soon as I use an expression for next page.

The pagination documentation seems to be missing crucial parts and only have a small example for other types of databases.

Hey @fwal — I'd be happy to take a look at your setup, would you mind writing into support chat and sharing screenshots of your setup so far?

Certainly! I'll do that now, thanks!

I have same issue, not obvious how to do pagination with Firestore. Can you update how to do this?

I'm still trying to figure this out together with support. Will also post here once working. :+1:

1 Like

Hello, I am trying to setup Firestore and pagination.

I'm trying to do server side pagination.

However it does not work for me also.

Any progress or success with this?


Hey @Jamie_Good — I was able to get this to work by setting Order by to the same filed that I used as my cursor. Here are some screenshots of my setup:

1 Like

Hi Chris,
many thanks for sharing this!

Unfortunately for me when I do this I do not get any values back from firestore.
Whenever I use the 'start At' field the query returns nothing !:man_shrugging:t2:
I am at a loss.

I have started to use MongoDB instead. Pagination seems to work ok there

Yes, I have had many headaches paginating Firestore. I've never done it ReTool but have in our api using the Firestore SDK. What I have found to work most accurately (for our data) and not produce duplicate results between pages is to use order by a createdDate field and use startAfter, not startAt as startAt returns the last record of the last paged set (again in our case). This doesn't so well to let you know ahead of time if there are "more pages."

In addition if we needed to sort with pagination by say, first name, they the firstName and createdDate would be used as the cursor to help ensure that results aren't duplicated between pages.

Our codebase is open source if anyone is interested in seeing this.

Sort by created date: Git Hub

sort by first name: Git Hub

1 Like

Appreciate the feedback brettski. Thanks for the links. I'll check them out. I'm using mongoDB so it's a problem for another day.