【发布时间】:2020-03-10 03:05:28
【问题描述】:
我在 firestore 中有下一个内容结构(一个频道集合,以及每个频道中的一个关注者子集合):
channels (is a collection):
- {channel id} (channel document id)
- name,
- description, ...
- followers (subcollection in every channel)
- {user id} (follower document id)
- state (user attribute) = 1 (is active),
我正在尝试查询以获取一位关注者的所有频道。类似于:
// dart
db.collection('channels').where('followers.$uid.state', isEqualTo: 1).snapshots();
其中 $uid 是有效的用户 ID。然后,查询结果必须返回用户作为关注者的所有频道。 我可以在频道中使用一组用户 ID 来做到这一点,但是我会有大量的关注者,并且在数组中,当我添加或删除关注者时,我必须在每次修改中读取和写入完整的数组。
谢谢!
【问题讨论】:
标签: dart google-cloud-firestore