In this video https://youtu.be/o7d5Zeic63s?t=145 it says there is a 1 write per second limit for a document.
If you are making a review application and you want to keep the number of reviews for 5,4,3,2,1 star ratings for a restaurant document how would you do that for an app with a large number of concurrent users then? Think of a popular app like foursquare... I think it would not be possible to keep the number of ratings in the restaurant document itself in this case like so:
Restaurant:
- name
- address
- ratings
- 1 start: count
- 2 stars: count
- 3 starts: count
- 4 stars: count
- 5 starts count
This would fail in case of more than 1 update attempts on the number of stars counts for the same restaurant, which is quite possible in this popular app case.
In this case, I can think of keeping a RATINGS sub-collection and recording a rating document for each rating. Then I could get the count of the ratings for a 4-star review. But, when I try to get the count of the documents with 4-star rating would it be like 30k read-billing if there are 30k 4-star ratings? How would you get this count without being charged for 30k reads?
How would you avoid this and how would you keep/update the number of star ratings for a restaurant?
Edit: I have seen this post: How to get a count of number of documents in a collection with Cloud Firestore
None of the proposed solutions work in this case. Since we are assuming there will be more than 1 increment/decrement per second in the count for a star rating.