ios - How to modify query with .whereKey, but utilizing multiple different parameters in Xcode? -
i creating application in xcode, using swift, pulling information parse-server database (hosted heroku). there convinient way modify query, can set up, example, follows:
let getfolloweduserquery = pfquery(classname: "followers") getfolloweduserquery.wherekey("follower", equalto: (pfuser.currentuser()?.objectid)!)
however, query query based on multiple parameters. here checking 1 column in db. there way modify query using .wherekey (or of same sort) such check multiple parameters/columns in db. essentially, checking these columns based on search parameters input user. user can select multiple parameters... query needs return objects fit all parameters, not one. there way that?
did check docs? says:
you can give multiple constraints, , objects in results if match of constraints. in other words, it’s , of constraints.
in case be:
let getfolloweduserquery = pfquery(classname: "followers") getfolloweduserquery.wherekey("follower", equalto: pfuser.currentuser()?.objectid ?? "") getfolloweduserquery.wherekey("anotherkey1", equalto: anotherobject1) getfolloweduserquery.wherekey("anotherkey2", notequalto: anotherobject2)
another option use nspredicate
:
let predicate = nspredicate(format: "follower = '\(pfuser.currentuser()?.objectid ?? "")' , anotherkey1 = '\(anotherobject1)' , anotherkey2 != '\(anotherobject2)'") let query = pfquery(classname: "followers", predicate: predicate)
Comments
Post a Comment