Firestore: Multiple 'array-contains'

后端 未结 2 1644
难免孤独
难免孤独 2020-12-01 11:15

I am trying to filter data with multiple where() methods using the array-contains operator, however I am having the following error:



        
2条回答
  •  一整个雨季
    2020-12-01 11:36

    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.

提交回复
热议问题