I'm using Parse.com as the backend for my app. In the backend I have the following classes:
User (objectId, name, username, password, etc)
Team (objectId, teamName, etc)
User_To_Team (objectId, teamId, userId)
The "teamId" and "userId" columns are pointers to the User and the Team classes.
I'm trying to query Parse in a way that will show me all of the Teams the user is associated with. I have tried the following, which doesn't work.
var innerQuery = PFQuery(className: "User_To_Team")
innerQuery.whereKey("userId", equalTo: PFUser.currentUser())
var query = PFQuery(className:"Team")
query.whereKey("objectId", matchesQuery:innerQuery)
query.findObjectsInBackgroundWithBlock {
...
}
I've the documentation, but they don't provide many examples.
I'm getting the following error:
[Error]: bad type for $inQuery (Code: 102, Version: 1.6.1) Error: Error Domain=Parse Code=102 "The operation couldn’t be completed. (Parse error 102.)" UserInfo=0x1702779c0 {error=bad type for $inQuery, code=102}, [error: bad type for $inQuery, code: 102]
---EDIT---
I'm now trying the following, which no longer generates an error, but doesn't generate any results either. I also changed the "Team" to "Squad", as teams will be referred to as Squads in the app. Just cleaner for me.
var innerQuery = PFQuery(className: "User_To_Squad")
innerQuery.whereKey("userId", equalTo: PFUser.currentUser())
var query = PFQuery(className:"Squad")
query.whereKey("objectId", matchesKey: "squadId", inQuery: innerQuery)