【问题标题】:How to query data with multiple where clauses from a Firestore 7.24.0 instance?如何从 Firestore 7.24.0 实例中查询具有多个 where 子句的数据?
【发布时间】:2022-01-19 22:52:58
【问题描述】:

我想根据两个 where 子句查询我的 Firestore 数据。

首先是spaceId == someString,其次是字段ìsDeleted == false。

我已经可以找到一个带有 where 子句的解决方案。但是,我找不到任何关于如何使用多个 where 子句进行查询的教程或文档,尤其是对于 Firebase 版本 7.24.0。

有人知道如何解决这个问题吗?

代码如下:

   this.activities = this.angularFirestore
      .collection("accounts")
      .doc(this.userId)
      .collection("activities", (ref) => 
        ref.where("spaceId", "==", this.spaceId)
      )
      .valueChanges();

【问题讨论】:

    标签: node.js angular typescript firebase google-cloud-firestore


    【解决方案1】:

    你可以只链接where 调用,所以:

    ref.where("spaceId", "==", this.spaceId)
       .where("isDeleted", "==", false)
    

    【讨论】:

    • 那行得通。谢谢!
    猜你喜欢
    • 2021-02-03
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-03-03
    • 1970-01-01
    • 2016-02-27
    • 1970-01-01
    • 2018-12-12
    相关资源
    最近更新 更多