【问题标题】:Invalid query. You cannot use more than one 'in' filter无效的查询。您不能使用多个“in”过滤器
【发布时间】:2020-06-13 22:00:12
【问题描述】:
this.ref.collection("users", ref => ref.where("uid1","in", [reciverId, senderId])
        .where("uid2","in", [reciverId, senderId]))

给我类似的错误

“无效查询。您不能使用多个 'in' 过滤器”

【问题讨论】:

    标签: javascript firebase google-cloud-firestore


    【解决方案1】:

    这确实是 Firestore 的限制,如 documentation 中所述:

    限制

    注意以下对 in 和 array-contains-any 的限制:

    • in 和 array-contains-any 支持最多 10 个比较值。
    • 每个查询只能使用一个 in 或 array-contains-any 子句。您不能在同一查询中同时使用 in 和 array-contains-any。
    • 您可以将 array-contains 与 in 结合,但不能与 array-contains-any 结合。

    【讨论】:

    • 有没有其他方法可以检查我有两个 id。 uid1 和 uid2 并且想要检查两者都存在,要么 uid1 = "reciverId" 要么 uid1 = "senderId" 要么 uid2 = "reciverId" 要么 uid2 = "senderId"
    • 您实际上是在尝试在这里进行 OR 查询,目前这是不可能的。您必须执行两个单独的查询,然后将结果合并到您的应用程序代码中。
    • @FrankvanPuffelen 我不清楚。我在链接多个数组包含时遇到相同的错误,但根据文档 (firebase.google.com/docs/firestore/query-data/…) “您可以链接多个相等运算符(== 或数组包含)方法来创建更具体的查询(逻辑与)”。我在这里错过了什么?
    • 你可以用一个array-contains链接相等操作,而不是多个。请参阅末尾的限制(Renaud 在他的回答中引用了):“每个查询最多可以使用一个 array-contains 子句。”
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2014-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-05-08
    • 1970-01-01
    • 2018-11-27
    • 1970-01-01
    相关资源
    最近更新 更多