Alek Piasecki Alek Piasecki - 9 months ago 44
Swift Question

How to set a PFQuery.wherekey to allow for multiple equalTo values?

I want to set a PFQuery's

equal to to an array's values (DB is a parse-server hosted by heroku). Is there anyway to set the
to allow for the value to be equal to any and all of the values within a particular array? For example:

let valuesArray = ["Hello", "Hi", "Hey"]
let query = PFQuery(className: "Example")
query.whereKey("values", equalTo: valuesArray)
query.findObjectsinBackground{ (objects, error) in
//append an array

I want the query to return all values in the parse-server DB that has "values" equal to any and all of the values in the
. This current set up does not work, so is there anyway to achieve this desired result?

Answer Source

I believe you can use containedIn instead of equalTo:

query.whereKey("value of the object", containedIn: valuesArray)