1MB exceed firestore

﹥>﹥吖頭↗ 提交于 2020-12-08 02:20:51

问题


I'm storing trip history (array-map) on firestore. the app is crash (Flutter app) when trying to store a large array map (array length may be more than 10,000). and also there are more than 30 fields on the same doc.

this is my map(list of map).

  Map<String, dynamic> toMap() => {
        "latitude": latitude,
        "longitude": longitude,
        "accuracy": accuracy,
        "altitude": altitude,
        "speed": speed,
        "speed_accuracy": speedAccuracy,
        "heading": heading,
        "time": time,
      };

Is there any solution to store this kind of array on firestore?


回答1:


It's not possible to exceed the max size of a document in Firestore.

What you should do instead is split each item of data into its own document, probably in a subcollection nested under a primary document.




回答2:


firestore documents have an upper limit of 1MB storage that does not mean that the developer has to fill it till 1MB. Heavier documents will have following disadvantes:

  1. In low network the document wont load.
  2. There is hardly a case when user need to access that much data. Single data model can not accomodate all the needs of an app so the data must be split into multple data models.
  3. There will be more egress charge for extra data being queried.

So you must model your database keeping these things in mind. As mentioned by Doug you should break your content into multiple documents.



来源:https://stackoverflow.com/questions/64391871/1mb-exceed-firestore

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