Reputation: 444
If this has already been answered please feel free to direct to a relevant Q&A. The only answer I have found is what I am already trying and I am not getting the result I am hoping for. Also looked over the REST API documentation for Parse and no luck in figuring this out. That being said...
I have two classes in Parse.com: Invites and Events Each Invite has a relation to an Event. Ideally I would like to query the Invite but also receive event_name and event_address from the Events object related to the invite.
This is the curl query I have been trying (pulled from the other answer I mentioned and Parse.com docs):
curl -X GET \
-H "X-Parse-Application-Id: xxxxx" \
-H "X-Parse-REST-API-Key: xxxxxx" \
--data-urlencode 'where={"$relatedTo":{"object":{"__type":"Pointer","className":"Events","objectId":"Yp04m8QT2N"},"key":"event_name"}}' \
https://api.parse.com/1/classes/Invites/XXQ0191KSv
Yp04m8QT2N is the related 'Events' objectId, event_name is in the Events class
I am getting results from the invite class but was expecting event_name to be included in the results. What am I missing? I haven't gotten as far as including multiple columns from events so if you could save me another question it would be much appreciated!
Response:
{"createdAt":"2014-06-07T20:26:04.877Z","event_objectId":{"__type":"Relation","className":"Events"},"invite_email":"[email protected]","invite_firstname":"Steven","invite_lastname":"Carlton","invite_opendate":{"__type":"Date","iso":"2014-06-08T19:16:00.000Z"},"invite_phone":"1234567890","invite_sentdate":{"__type":"Date","iso":"2014-06-07T20:26:00.000Z"},"objectId":"XXQ0191KSv","updatedAt":"2014-06-08T19:17:17.980Z"}
Thanks for your help!
Upvotes: 1
Views: 1522
Reputation: 6289
if it really is a pointer, then as docs say in 'retreiving objects' section , you can just do
--data-urlencode 'include=$pointer'
where $pointer is the field name in Invites whose value is the pointer to Events.
If you are useing a relation type instead of a pointer then you can not flatten the query in this way.
Upvotes: 3