Dan Lloyd
Dan Lloyd

Reputation: 3

How to use array-contains in firestore web interface

I'm trying to filter a firestore collection based on an object in an array. I have an array of categories and I want to filter by a specific category. I read in this answer that you have to use the full object as the query value.

In this example, the object is {'level': 1, 'name': "Furniture"}

If I use this value through the API using node it returns relevant documents.

However when I'm running the query in firestore's web interface, it's not returning any matches. I'm guessing it's because it's wrapping the object in quotes because the data type is a string...

query from node:

.collection("products").where("categories", "array-contains", {'level': 1, 'name': 'Furniture'})

query preview when using firestore web interface:

.collection("products").where("categories", "array-contains", "{'level': 1, 'name': 'Furniture'}")

Is this a limitation of using the web interface or am I doing something wrong here? The only data types I can use in array-contains are string, number and boolean.

Upvotes: 0

Views: 150

Answers (1)

Doug Stevenson
Doug Stevenson

Reputation: 317467

This is a limitation of the web interface. It doesn't give you the ability to specify an object parameter to the query. You could file a feature request with Firebase support to ask for this if it's important to you.

Upvotes: 1

Related Questions