【问题标题】:Is there a maximum number of attributes for documents in Firebase?Firebase 中文档的属性数量是否有上限?
【发布时间】:2019-07-11 11:07:36
【问题描述】:

我正在开发一个使用flutterFirebase 来存储数据的游戏保护应用程序。

其实我的Firebase 数据库是这样的:

games:{<br>
   // Team 1<br>
   player1: (reference to a player),<br>
   player2: (reference to a player)',<br>
   // Team 2<br>
   player3: (reference to a player),<br>
   player4: (reference to a player),<br>
   scoreTeam1: 2,<br>
   scoreTeam2: 1<br>
}<br>

// Usergames documents are indexed by the player unique ID as a key<br>
userGames: {<br>
   count: 2,  //this variable is increased every time i add a new game<br>
   game1: (reference to a game),<br>
   game2: (reference to another game),<br>
   ...<br>
   gameN: (another reference)<br>
}<br>

Player:{<br>
   name: 'player name'<br>
   ...(another player data)<br>
}<br>

有了这个实现,userGame 文档每次都会有更多的字段。 我的问题是文档可以包含的字段数量是否有限制。另外我想保存很多游戏,这是实现数据库的正确方法吗?

【问题讨论】:

    标签: firebase flutter dart google-cloud-firestore


    【解决方案1】:

    Firebase 使用限制可在此处找到:

    https://cloud.google.com/firestore/quotas#collections_documents_and_fields

    从该页面开始,字段数没有限制。但是,单个文档的最大大小为 1MiB。

    我会考虑使用子集合来存储游戏结果,而不是在文档中添加越来越多的字段。

    【讨论】:

      【解决方案2】:

      你可以看到firebase限制这个:https://firebase.google.com/docs/database/usage/limits?authuser=0

      至于数据库结构,我建议您将一般结构分解为实体并存储它们,而对于更复杂的对象,则存储对这些实体的引用(id)。

      关于游戏数()——读取分支时可以获取,如dataSnaphot.childrenCount。

      【讨论】:

        猜你喜欢
        • 2012-03-06
        • 1970-01-01
        • 2018-07-03
        • 2019-07-12
        • 2015-01-13
        • 1970-01-01
        • 1970-01-01
        • 2020-12-13
        • 2017-01-24
        相关资源
        最近更新 更多