Firestore: Multiple 'array-contains'

Solution 1:

One solution would be to store the 'tags' in an Object as its property names.

node_sku = {
  "sku1": true,
  "sku2": true,
  ...
  "skun": true
}

Then you can create the AND WHERE clauses like this:

list.forEach( (val) => { 
  ref = ref.where(`node_sku.${val}` , '==' , true);
});

This approach is an answer to the question "without having to query them individually". However, as soon as you want ordering and pagination, you will run into another invisible brick wall of compound indices.

Solution 2:

As you've found you can only have a single array-contains operation in a query. The idea of allowing multiple is currently not supported, but could be valid. So I recommend you file a feature request.

The only solution I can think of for your use-case right now, is to also include the combinations. So if you want to allow testing for the existing of two SKUs, you explode the array to also contain each combination (merging keys in lexicographical order):

product1 
  - node_sku ['sku1', 'sku2', 'sku3', 'sku1_sku2', 'sku1_sku3', 'sku2_sku3' ]

For two that might still be reasonable, but the combinatory explosion will make it infeasible beyond that.