I am trying to query for all of the existing users in my app that the user has not added as a "Friend". I am getting the error
Cannot do a comparison query for type: PFRelation
Here is my current code:
override func queryForTable() -> PFQuery {
let currentFriends : PFRelation = PFUser.currentUser()!.relationForKey("friends")
// Start the query object
let query = PFQuery(className: "_User")
query.whereKey("username", notEqualTo: currentFriends)
// Add a where clause if there is a search criteria
if UserInput.text != "" {
query.whereKey("username", containsString: UserInput.text)
}
// Order the results
query.orderByAscending("username")
// Return the qwuery object
return query
}
How do I solve this issue? Thanks
I solved my problem.... in a way. I was unable to compare the PFRelation so I created a helper Parse class that saves the user who adds the other user as "from" and the user they add as "to" then I am able to compare them like this.
let currentUser = PFUser.currentUser()?.username
let currentFriends = PFQuery(className: "Friends")
currentFriends.whereKey("from", equalTo: currentUser!)
// Start the query object
let query = PFQuery(className: "_User")
query.whereKey("username", doesNotMatchKey: "to", inQuery: currentFriends)
I hope this helps someone in the future.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With