2021年1月4日星期一

how to get the number of documents upfront without reading documents - Firestore - Swift

I'm using pagination to reduce the number of calls with Firestore, I managed to set it up correctly.

But I also need to get the total number of all the documents upfront corresponding to the query which looks something like this:

let query = db.collection("Posts").document(uid).collection("Posts").order(by: "timestamp", descending: true)  

If I need to get the total number of documents upfront what's the point in paginating? Is there a point to it?

To be clear I only need the number of documents and not to read them all at the beginning.

https://stackoverflow.com/questions/65570791/how-to-get-the-number-of-documents-upfront-without-reading-documents-firestore January 05, 2021 at 06:38AM

没有评论:

发表评论