firebase - 如何在 Firestore 中存储有关集合的元数据?

标签 firebase google-cloud-platform google-cloud-firestore

我经常遇到关于存储有关集合的一些元附加信息的问题。

Firestore 上有什么方法可以在集合中保存一些元信息吗?就像维护此集合的目的或其他一些自定义属性一样。

例如:在保存排行榜分数时,如果我们需要知道查询时分数是否需要升序或降序排序,最好将这些信息存储在集合中。

否则,当我们需要对分数进行排序时,我们需要进行额外的读取。谁能推荐一下吗?

最佳答案

documentation 中所述:

Following Cloud Firestore's NoSQL data model, you store data in documents that contain fields mapping to values. These documents are stored in collections, which are containers for your documents that you can use to organize your data and build queries.

换句话说,Firestore 中的“数据容器”就是文档。集合只是文档容器,不能保存数据(即“映射到值的字段”)。

因此,如果您想存储有关特定集合的额外信息(即元数据),则必须在文档中执行此操作。是的,它需要额外的读取来查询包含这些元数据的文档。

关于firebase - 如何在 Firestore 中存储有关集合的元数据?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56393090/

相关文章:

firebase - 带有特殊字符的 Firestore 查询属性

firebase - 在 Firestore 中存储(可能)巨大列表的最佳方式是什么?

android - Firebase 远程配置重叠条件组

javascript - 在 React js 中从 firebase 数据库信息设置状态

Kubernetes 自动缩放器 objective-c PUUtilizationPercentage

javascript - 如何将数组中的 JSON 数据保存到 Firestore

javascript - 如何检查日期并显示消息 - Javascript

java - 使用 ValueProvider 从 Dataflow 模板读取 BigQuery 时出现异常

google-cloud-platform - 使用 'gcloud run deploy' 时,如何使用命令行参数指定服务名称?

java - 对 Firebase Firestore Android 中的数据执行添加/操作