Firestore storage size limit how to store large arrays

假装没事ソ 提交于 2020-01-24 20:50:51

问题


I got a collection users/$userID/followers this user ID is the firebase UID so is 29 bytes long ( String sizes are calculated as the number of UTF-8 encoded bytes + 1.)

Inside each user document i got a array named followers and another named following. Both arrays contain a lot of userID's so here's the problem.

In firestore each document has a max size of 1mb so it's easy to see I'm gonna run out of space soon. My question is what's the best way to manage large arrays like this ones.

Most obvious option: Create another document, containing just a pair of new arrays to continue saving this data ( and do this in a recursive way when the limit of the document is reached).

So some better idea? Or at least how to simplify the process a little bit.

More info about size limits here: https://firebase.google.com/docs/firestore/storage-size?hl=en-419


回答1:


If you're concerned about the size of an array, you should instead split each item out of the array and make it its own document. This is the only way you will achieve massive scalability with Firestore for storing many individual items.

Yes, it will cost more. There is a cost to scalability.



来源:https://stackoverflow.com/questions/54881751/firestore-storage-size-limit-how-to-store-large-arrays

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!