gpt4 book ai didi

javascript - Firebase Firestore 获取用户相关数据

转载 作者:行者123 更新时间:2023-12-01 02:14:06 24 4
gpt4 key购买 nike

在我的 Firestore 数据库中,我有两个集合:用户。 Feeds 包含有关该字段的数据,例如评论、关注者...等。关注者数据类型是一个简单(字符串)数组。

我的问题是,如何获取关注者数组包含用户 ID 的每个提要?除了查询所有提要并在 foreach 中选择相关提要之外,还有其他方法吗?

最佳答案

无法根据数组字段的内容查询文档。来自 documentation :

Although Cloud Firestore can store arrays, it does not support querying array members or updating single array elements. However, you can still model this kind of data by leveraging the other capabilities of Cloud Firestore.

如果您只想查询具有特定关注者的字段,您应该使用对象字段而不是数组。

文档的同一页继续描述将数组转换为对象的策略。如果用户关注该 feed,该对象会将用户 ID 映射到 bool 值 true

关于javascript - Firebase Firestore 获取用户相关数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49573627/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com