Oleksandr Matrosov
Oleksandr Matrosov

Reputation: 27133

Retrieve more information from PFUser pointers using joint class

I have Project, User and joint class ProjectEmployee. ProjectEmployee contains pointers to a Project and to a User. I will skip other params as they unneeded for this example.

When I do employee fetch it returns for me only pointers. Which looks like ok for performance.

This is how I save ProjectEmployee

let parseObject = PFObject(className:"ProjectEmployee")

parseObject["active"] = true
parseObject["user"] = pfUser
parseObject["project"] = pfProject
parseObject["occupation"] = pfOccupation
            
parseObject.saveInBackground

My question how can I get ProjectEmployee with more information. For now I just see pointers when I do fetch from backend database. Which is correct, but I need more information about User and Project.

let query = PFQuery(className:"ProjectEmployee")
query.findObjectsInBackground 

For example I need to get username of User and etc.

The main issue I am trying to solve is to filter a list of user which are in the project already but using joint class.

When I am on the project details screen I show all User records in table view. I select the users and as I have Project object and array or User objects I create joint class ProjectEmployee. But next time I open project details screen I want to show all User records excluding the users I already added to a Project

I guess the question could be separated to two subquestion.

  1. Do I need to fetch pointers info via additional query, if so how to do it right.
  2. Do I need to use joint class for this purposes

Upvotes: 0

Views: 38

Answers (1)

Erk
Erk

Reputation: 26

Here is an example of relational queries at Parse: http://docs.parseplatform.org/ios/guide/#relational-queries

Upvotes: 1

Related Questions