Jacob Rohde
Jacob Rohde

Reputation: 921

Eager loading Parse current user

When getting the current user, I would like to eager load some of there user properties. I now when using a query it is possible to use an "include" to eager load some properties. Who would I do that with the current user? I can't seem find it in the docs.

A hack would be to read the id of the current user and then do a query on the user class - but perhaps I am missing something?

Upvotes: 0

Views: 125

Answers (1)

Timothy Walters
Timothy Walters

Reputation: 16874

What you have described is the correct way of doing it, get the id of the current user and do a get on that user, using includeKey: for anything you want included (such as your array).

PFQuery userQuery = [PFUser query];
[userQuery includeKey:@"nameOfArrayColumn"];
[userQuery getObjectInBackgroundWithId:[PFUser currentUser].objectId block:^(user, NSError *error) {
    // do something with the populated user object
}];

Upvotes: 2

Related Questions