gpt4 book ai didi

firebase - Firestore : How to query a map object inside a collection of documents?

转载 作者:行者123 更新时间:2023-12-01 10:19:37 30 4
gpt4 key购买 nike

我的目标:

网络应用程序(类似于Google云端硬盘)有2个屏幕。

第一个屏幕是“我的故事”,其中显示了我是所有者的所有故事文档。

第二个屏幕是“与我共享”,其中显示了我是读者,作家或评论者的所有故事文档。

我们有这个/stories/{storyid}

{
title: "A Great Story",
content: "Once upon a time ...",
roles: {
alice: "owner",
bob: "reader",
david: "writer",
jane: "commenter"
// ...
}
}

完整的数据结构引用: https://firebase.google.com/docs/firestore/solutions/role-based-access

问题:如何编写以下查询以实现上述目标?
db
.collection('stories')
.where(`roles.${uid}`, '==', 'owner')

上面的查询不起作用,因为它将要求Firestore索引role.alice,roles.bob,roles.david,roles.jane和Roles。[all_uid]。

编辑#1:找到相关帖子(无答案),询问有关 Firestore querying with roles的信息

最佳答案

现在您可以过滤...

db
.collection('orders')
.where('orderDetails.status', '==', 'OPEN')
它将检查属性 中状态的字段 订单详细信息是否等于“OPEN”

关于firebase - Firestore : How to query a map object inside a collection of documents?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54811320/

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