Home > database >  Firestore How can i get subcollections of a collection
Firestore How can i get subcollections of a collection

Time:12-01

I want to get subscriptions of users.
I can get user one by one then get each user subscriptions.
But this will make many document reads.
i want to get subscriptions 10 by 10 sorted by newest.
is that possible?

Firestore path

CodePudding user response:

Subcollections: Firestore query subcollections

Pagination: https://firebase.google.com/docs/firestore/query-data/query-cursors

Be aware that asking questions in this way lowers the chances of getting answers.

CodePudding user response:

we can get users one by one then get each user subscription but this will make many reads

It doesn't matter if you get the documents one by one, or all documents at once, you'll always pay the same price. What I mean is that if you perform a query that returns 5 documents, you'll have to pay 5 read operations. If you read each of those 5 documents, one by one, the same number of read operations you have to pay.

I want to get subscriptions 10 by 10 sorted by newest is that possible?

In that case, you have to perform a query. For that, I recommend you start with the official documentation.

  • Related