【问题标题】:Hierarchic structure Firestore and subcollections分层结构 Firestore 和子集合
【发布时间】:2017-11-27 11:24:29
【问题描述】:

我正在尝试使用 Cloud Firestore 构建数据库,并阅读了有关 hierarchic structure 的文档,我找到了文档示例中存在的另一种解决方案。

我有一个collection 的类别,每个类别都可以有子类别。虽然我可以使用 Firestore 文档示例中提供的系统,例如 collection/document/subcollection/document...,但我发现 another example 用于 MongoDB,它没有使用子集合,而是使用具有父子关系的单个文档中的嵌套数据,如下图所述

如果我希望user 能够查看所有子类别以便用户可以对某个event 进行分类,那么哪种方法更好?更好的意思是避免与数据库的多个连接(因为这是 Firestore 的价格)。

【问题讨论】:

    标签: mongodb hierarchical-data google-cloud-firestore


    【解决方案1】:

    本文档讨论嵌套数据及其权衡,"Choose a Data Structure"。我不确定关于定价的多个连接的陈述是否正确。 Firestore charges for number of operations, storage, and network bandwidth.

    如果所有用户共享一个类别列表,您将能够使用当前结构通过一次操作检索整个列表。注意有一个1 MiB limit for document size

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2021-05-22
      • 2018-05-01
      • 2011-07-10
      • 2021-01-25
      • 1970-01-01
      • 1970-01-01
      • 2020-08-19
      相关资源
      最近更新 更多