0

Note A POC is included below

Note I have checked this question: Firebase Firestore - Filter data with multiple 'array-contains'

Project Stack:

Overview of the issue/question:

In a Firebase document, we have 2 attributes with <Array> type

const Pitch = {
  // ...
  formats: [],
  themes: []
}

When trying to filter pitch documents based on both fields, we get trapped in a corner where there is a Firebase caveat in Compound queries FirebaseError: [code=invalid-argument]: Invalid query. You cannot use more than one 'array-contains' filter

Actual POC

The following sandbox illustrates the actual complex component: https://stackblitz.com/edit/nuxt-starter-8dqt1c?file=README.md

Question

What's the best workaround to get the filtration scenario easier as a development experience?

3
  • 1
    Well, I think you can merge the formats and themes into one array. (Or you can add a separate array for that) and store the values like : format__theme and query it like acc.where('format_theme', 'array-contains','format1__theme2' ) Commented Feb 6, 2023 at 20:22
  • @Eldar, I will consider that approach, thank you :) Commented Feb 7, 2023 at 17:17
  • Actually formats is an string[], however, themes is an object[]. Commented Feb 10, 2023 at 20:48

0

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.