Hello guys, I'm currently building an app that needs a folder/file
data structure
I noticed there are 3 ways of data modeling this kind of stuff in Firestore
1. Using document reference for the items of a folder
2. Embed the item itself inside the folder doc
3. Adding a subcollection to each folder
Please note that I will need all the items when querying the folder (the item won't be accessed by itself)
I'm curious about which one is the best way to do this.
There is no straight solution to this but let me put my views
Firestore is designed to handle millions of documents but each document has a limitation of 1MB.
The limitation is definitely a problem if you are trying to store the data in a document which keeps increasing.
Being said that, I see 2 solutions based on constraints
If you can hold the items(files list) data in a 1MB in a folder document, go ahead with this as its the best efficient for storing as well as for querying.
Mimic the same folder/file structure in firestore with collection/documents hierarchy and this is more scalable. But has the down side of number of reads.
Find out how many file details you can save in 1MB if it's fits your usecase, thats the best to go. May be you can go with multiple documents per folder too which may not be quick to manage(code) but saves a lot.
I'm not sure how your item/file details be like so can't go deep further.
Awesome! Thanks for the tip :)