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

StackOverflow https://stackoverflow.com/questions/23586747

  •  19-07-2023
  •  | 
  •  

Frage

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?

War es hilfreich?

Lösung

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.

Andere Tipps

swift 3.0

let Query:PFQuery = PFQuery(className: “className”)
Query.whereKey(“Field Name”, containedIn: array)// [“1”,”2”,”3”];
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top