Adnan Fayaz
Adnan Fayaz

Reputation: 167

Mutiple 'in' Operators from single collection in firebase cloudstore query

I have a firebase query, (Pseudo Code)

collectionName
, ref => ref
.where('field1' , 'in', array1)
.where('field2' , 'in' , array2)
.snapshotChanges()
.pipe(map(actions  => {
 return actions.map(a => {
    /* Some more Code */
  })
})

I need to keep multiple 'in' operators to fields data from FB Cloud Firestore. I'm facing issues in doing so with error as cannot have multiple in the operator in a single query. Is there any way where can I fetch records from only based on this query. I've no intention in using single IN operator in the query to fetch all records from FB and filter it in Client-Side

Upvotes: 0

Views: 76

Answers (1)

Doug Stevenson
Doug Stevenson

Reputation: 317427

I need to keep multiple 'in' operators to fields data from FB Cloud Firestore.

The documentation is pretty clear that this is not possible.

Note the following limitations for in and array-contains-any:

  • in and array-contains-any support up to 10 comparison values.
  • You can use only one in or array-contains-any clause per query. You can't use both in and array-contains-any in the same query.
  • You can combine array-contains with in but not with array-contains-any.
  • You cannot order your query by any field included in an equality (=) or in clause.

These are hard limitations. There are no simple workarounds. Consider restructuring your data so that the query you want to perform is possible, or performing multiple queries, and computing the intersection of their results.

Upvotes: 1

Related Questions