hugocarlmartin
hugocarlmartin

Reputation: 719

Parse: Match query with query to pointer

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)
    }
  }
} 

Upvotes: 1

Views: 609

Answers (1)

Jake T.
Jake T.

Reputation: 4378

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")

Upvotes: 2

Related Questions