0

Note A POC is included below

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

Project Stack:

  • Nuxt@2.15.8
  • @nuxtjs/firebase

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?

Eldar
  • 9,781
  • 2
  • 10
  • 35
Nasr Galal
  • 31
  • 6
  • 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' )` – Eldar Feb 06 '23 at 20:22
  • @Eldar, I will consider that approach, thank you :) – Nasr Galal Feb 07 '23 at 17:17
  • Actually `formats` is an `string[]`, however, `themes` is an `object[]`. – Nasr Galal Feb 10 '23 at 20:48

0 Answers0