Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
200 views
in Technique[技术] by (71.8m points)

javascript - Parse: Include nested pointers in query

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?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...