Home > Net >  How to use whereIn filter multiple times in a query
How to use whereIn filter multiple times in a query

Time:01-26

I am using this code to retrive data from firestore

querysnap = FirebaseFirestore.instance
                              .collection("datas")
                              .where("cat", whereIn: Cateogryarray )
                              .where("City", whereIn:Cityarray)
                              .snapshots();

Then I get this error.

You cannot use 'whereIn' filters more than once.

How can I execute this query.

CodePudding user response:

As the Firestore documentation on query limitations says:

You can use at most one in, not-in, or array-contains-any clause per query. You can't combine these operators in the same query.

Since you're trying to use two in clauses in your query, Firestore gives an error.

The most common workaround is to run with one clause against the database (typically the one you expect to exclude most documents from the result), and perform the rest of the filtering in your application code.

CodePudding user response:

Check out in the official documentation:

https://firebase.google.com/docs/firestore/query-data/queries#limitations_2

  •  Tags:  
  • Related