Home > other >  How to query data with multiple where clauses from a Firestore 7.24.0 instance?
How to query data with multiple where clauses from a Firestore 7.24.0 instance?

Time:12-17

I want to query my Firestore data depending on two where clauses.

Firstly the spaceId == someString and secondly the field ìsDeleted == false.

I could already find a solution with one where clause. However, I could not find any tutorials or documentation on how to query with multiple where clauses, especially for Firebase version 7.24.0.

Anyone an idea how to solve this?

Here is the code:

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

CodePudding user response:

You can just chain where calls, so:

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