1

Please take a look at this example: enter image description here

As you see I have a collection called "new_letters" and inside there I have documents, which also have collections and in those also documents, so basicly a long chain of data segments always.

My goal would be to have a listener which checks the amount of documents inside of "new_letters" and my idea would be the simple one following:

var counter = firebase.firestore().ref("new_letters").onSnapshot(snapshot => {
   return snapshot.size
});

My problems are the following:

  • Im afraid of long bills and therefore I only want to check the amount of the data, not every subcollection of subdocument included in the collection "new_letters". If I do the listener like above, will I only download the 3 documents or will this also include the "inbox"-collection which is inside of the second document for example?
  • Incase Point 1 is true and I download all data, including each "inbox" inside every document in "new_letters", is the only alternative making a counter for example in the firebase.database() and listening only to that?

Im looking for a solution which is the least recource-consuming.

Frank van Puffelen
  • 565,676
  • 79
  • 828
  • 807
  • 1
    Does this answer your question? [Cloud Firestore collection count](https://stackoverflow.com/questions/46554091/cloud-firestore-collection-count) – Alex Oct 18 '21 at 22:31

0 Answers0