Firestore orderby desc startAt returning no results

Viewed 137

I have a collection I would like to query the results from in database. I need to order by descending and would like to "skip" x records and retrieve x records each time. The current query I'm using, doesn't return any results despite the fact there are 24 items in the collection. Changing startAt returns results, but in wrong order.

   const snapshot = await db.collection('Conversation')
        .doc("c0mZfX1ZkfathIwwYkMX")
        .collection('results')
        .orderBy('createdAt', 'desc')
        .startAt(10)
        .limit(10)
        .get()

Is there a way I can paginate the results and make this query return results without keeping a reference to the last retrieved snapshot?

0 Answers
Related