Filter array contains only

Is it possible to use the Filter API to find documents with an array field that contains only the specified values?

Eg. I need to find documents with {array_attr: ["A", "B", "C"]}. I do not want documents that may have {array_attr: ["A", "B", "C", "D"]}

Hey Steve ~

Thanks for the post.

My first thought is: no, this isn't supported.

There is no way to clearly say: "I want documents with the ["A", "B", "C"] array but not the ["A, "B", "C", "D"] array.

As you likely read in the filters documentation, we have clauses that you can apply to filters: ANY, ALL, NONE. The clauses work on individual values, which can be placed within an array, but not array values.

Can you please share some more details about your use case? We might be able to get creative.

Enjoy the day,

Kellen

1 Like

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.