0

I'm trying to find an element of an array field in my firestore collection.

This is the field in firestore:

channels: [{name: "linkedin", date: "2020-01-02"}]

This is how I tried querying it:

firebase.firestore().collection("users")
  .where("status", "==", "ACTIVE")
  .where("channels", "array-contains", {
      name: "linkedin"                     
  })

1 Answer 1

1

array-contains can`t perform search into objects specific values for properties.

it would work if you do something like channels: ["Linkedin", "facebook", "twitter"]

Probably you want to try to use a subcollection for channels instead, otherwise, you need to fetch all the values into channels and then apply filters in memory.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.