Search code examples
parse-platform

Parse.com query objects where the key's array value contains any of the elements


on https://parse.com/docs/js_guide#queries-arrays there is an example how to find objects where the key's array value contains each of the elements 2, 3, and 4 with the following:

// Find objects where the array in arrayKey contains all of the elements 2, 3, and 4.
query.containsAll("arrayKey", [2, 3, 4]);

However, I would like to find objects where the key's array value contains at least one (not necessarily all) of the elements 2,3, and 4.

Is that possible?


Solution

  • I'm not positive, but what happens if you try containedIn?

    I think if you pass an array, it checks to see if any are contained.

    query.containedIn("arrayKey", [2,3,4]);
    

    I know that if you use equalTo with an array key and a singular value, it checks if the value is in the array and returns TRUE. I think this will do something similar and should work. I think it will check if any value in "arrayKey" is in the passed array. If any key object does, it will return the object.