当我尝试使用 IN 查询过滤数据时,它没有向我显示结果,我在结果中得到一个空白数组,我在 firebase 控制台中尝试了同样的操作。我在那里也没有得到结果。
我的数据是 messages/01fjubNOf8oYODitr1h6 在此路径中,我有键 - 名称、消息、参与者
{
name: "Pawan arora",
message: "test",
participants: ["33", "127"]
},
{
name: "TEST NAME",
message: "not working",
participants: ["114", "127"]
}
{
name: "TEST DATA",
message: "new",
participants: ["114", "33"]
}
我尝试在查询中过滤我的查询的数据
.collection("messages").where("参与者", "in", ["33", "127"])
这里我应该得到第一个对象作为结果
最佳答案
过滤数组时需要使用array-contains-any
运算符。
试试这个:
.collection("messages").where("participants", "array-contains-any", ["33", "127"])
详情查看this blogpost .
关于javascript - Firebase - IN 查询在 where 子句中不起作用,结果为空数组,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/65610942/