1

So I'm trying to get all UserSports that has a user (pointer to User) with the matching facebookId in User from facebookIdList. facebookIdList contains the id:s. But objects has 0 values. Any ideas?

let userQuery = PFQuery(className: "User")
userQuery.whereKey("facebookId", containedIn: facebookIdList)

let query = PFQuery(className: "UserSport")
query.whereKey("user", matchesQuery: userQuery)
query.includeKey("user")

query.findObjectsInBackgroundWithBlock { (objects, error) -> Void in
  if error == nil {
    if let userSports = objects as? [UserSport] {      
      print(userSports)
    }
  }
} 
3
  • 1
    Try executing the User query by itself to make sure it's returning what you expect Commented Oct 7, 2015 at 18:42
  • 1
    What @Russell said. Also, double check that your keys match. They're case sensitive, so maybe you have a "User" key instead of "user", or "faceBookId" instead of "facebookId" Additionally, I know that the objective-c SDK has a specific query for users that you're supposed to use ( [PFUser query] ), so perhaps there is a similar thing for Swift. I bet that your userQuery isn't querying the User class the way you'd expect it to be. Commented Oct 7, 2015 at 19:44
  • 1
    Good catch @Jake T., The problem is definitely that that he is incorrectly querying for Users Commented Oct 7, 2015 at 20:03

1 Answer 1

2

It looks like you aren't querying the User class properly. See This StackOverflow answer. You should be using the class "_User", or, more appropriately, var query : PFQuery = PFUser.query() instead of var query : PFQuery = PFQuery(className: "_User")

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.