Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Parse: Include nested pointers in query

Tags:

I have the following structure in my app:

MessageRecipients -> Message -> User 
                     Message -> Activity

where the -> represent a pointer. I have separated out the messages and message recipients tables because I need to capture whether the message has been read by each recipient.

The query I want to do is find all of the messages for a recipient. So I need to include the message in the MessageRecipients query but I would also like to include the nested User and Activity objects.

var MessageRecipient = new Parse.Query('MessageRecipient');
messageQuery.equalTo('recipient', query.recipient);
messageQuery.include('message');

The message comes back without the activity and sender populated. I tried calling messageQuery.include('activity') but that didn't work as activity is not on the correct table.

Is there a way to do this query or do you have to do separate queries for the nested objects?

like image 666
rorymadden Avatar asked Jul 01 '14 17:07

rorymadden


1 Answers

You'll need to include those sub-sub-objects as well:

messageQuery.include('message');
messageQuery.include('message.user');  // if user is the column name
messageQuery.include('message.activity'); // if activity is the column name
like image 196
Fosco Avatar answered Oct 08 '22 20:10

Fosco