小编AD *_*ark的帖子

Firestore 查询 - 一对多关系

我将开发 android 移动应用程序并使用 Firebase 作为后端。我是 NoSql Firestore 的新手。

在我的应用程序中,用户有很多主题。一个主题有很多帖子,帖子有很多评论和一张图片。用户也有很多追随者。

在这种情况下,如何根据我的要求设计 Firestore 数据库以及最佳实践是什么?如何减少阅读次数?

以下结构适合我的要求吗?

Firestore-root
    |
    --- Topic (collections)
    |     |
    |     --- topicId (document)
    |            |
    |            --- topicId: "345"
    |            |
    |            --- title: "Topic Title"              
    |            |
    |            --- viewCount: 20
    |            |
    |            --- likeCount: 30
    |            |
    |            --- Posts (colletion)
    |            |     |
    |            |     --- postId
    |            |            |
    |            |            ---postId: "321"
    |            |            |
    |            |            ---Title: "My title"
    |            |            | …
Run Code Online (Sandbox Code Playgroud)

android nosql firebase firebase-realtime-database google-cloud-firestore

6
推荐指数
1
解决办法
5154
查看次数