Alek Piasecki Alek Piasecki - 28 days ago 12
Swift Question

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

I want to set a PFQuery's

.whereKey
equal to to an array's values (DB is a parse-server hosted by heroku). Is there anyway to set the
.whereKey
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
valuesArray
. This current set up does not work, so is there anyway to achieve this desired result?

Answer

I believe you can use containedIn instead of equalTo:

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