Reputation: 2760
I have a Post class and I want to get the products associated to it. I'd like to write a single query that fetches all of the posts with the products associated to them. Below is a rough idea of what I'd like the hash to looks like.
Schema:
Post - objectId, title
PostItem - post(pointer), product(pointer)
Product - objectId, title, price
Output I want {'results': [{'objectId':'blah', 'title':'The Post', 'products': [{'objectId':'14', 'title':'First product', 'price':'20' }, {'objectId':'26', 'title':'Second product', 'price':'55' }] }, {'objectId':'blah2', 'title':'Second post', [{'objectId':'38', 'title':'Some product', 'price':'54' }, {'objectId':'26', 'title':'Another Product', 'price':'88' }] }] }
Is this possible to do in one query? How would I do this using curl and parse.com?
Upvotes: 1
Views: 191
Reputation: 400
You'll want to use the include
key option alongside pointers. Since it's been nearly a year since you posted, I assume you figured it out, but lurkers can read more about this (in Javascript) here.
Upvotes: 0