Issues with server side pagination of Firestore

Hi @Joe_dare, it looks like "data" is not defined in the query you shared. I tried @Kabirdas' query on my end and I got it to work by making a small change to it.

Try this approach using the new Table Component, and it should work like a charm:

Add-ons:

  1. "Pagination: Server-side."
  2. Any other add-on you need.

Event handlers:

  1. "Change page: queryWeAreWorkingOn.trigger()"

Here is the setup that works on my end:


Here is the query so you can just copy and try on your end:

const TIMESTAMP_KEY = "created_at"
const data = []

await db
  .firestore()
  .collection("users")
  .orderBy(TIMESTAMP_KEY, "desc")
  .limit(table1.pagination.pageSize || 27)
  .offset(table1.pagination.currentPage * 27)
  .get()
  .then((querySnapshot) => {
    querySnapshot.forEach((doc) => {
      const values = doc.data();
      let createdAtValue = values[TIMESTAMP_KEY];

      createdAtValue = new Date(createdAtValue);
      
      data.push({
        ...values,
        [TIMESTAMP_KEY]: createdAtValue,
      });
    });
  });

return data;


With this query and table setting, I am able to change pages and the table refreshes with the expected data. :card_file_box:

Let us know if this worked or if you have any questions! :slightly_smiling_face: