I am using a Map field to store all the medical aid IDs of a member. I don’t want to use a subcollection because its maximum depth is only 100. The medical aid of a member can reach more than 100.
Here is an example of my map field:
medicalAids:{ id1: true, id2: true, id3: true}
How many ids I can store in this medicalAids (map)?
Should I use subcollection instead?
>Solution :
What you’re describing isn’t called "depth". That’s simply the number of nested map fields. You can have as many map fields as you want, up to the max size of a document, which is 1MB. Learn how to calculate the size of a document using the documentation.
Subcollections are not limited in number of documents. The max subcollection depth you’re referring to is talking about nested subcollections, not number of documents. If you have an unbounded number of items to store, you should definitely do that using documents in a subcollection, not a map field, because you will run out of that 1MB space.