Reputation: 33
In a firestore document, there can be 20000 fields max. This would be a huge problem to something like comments and replies. A document for comments can have fields for each comment with subfields for comment meta data(eg. time,comment text , comment by,etc). Further for each comment field(which is in the form of a map), can have another map for replies. This would easily and in no time consume those 20000 fields. If we use sub collections for each document or even each reply then it would just cost huge for reads as the number of comments and replies grow. Please tell me if i am missing something and the solution for this problem as till now firestore was my favorite, but now i feel i need to switch to something else :(
Thanks in advance...
Upvotes: 3
Views: 447
Reputation: 317750
You are not missing anything. This is the way Firestore works. Using subcollections is the way to handle unbounded lists of data. It's suggested to get creative (making changes to both the data and the app) when populating massive collections in order to reduce your reads.
If there are alternatives to Firestore that better meet your needs, then it's a good idea to consider them as well. Firestore doesn't solve every problem for every app.
Upvotes: 4