Craigt
Craigt

Reputation: 3580

Fetch all related classes in Parse

Lets say I have four classes in Parse.com

[Restaurant] -has many-> [Review], [Food], [Wine]

So basically, a [Restaurant] has a list of reviews, a list of food and a list of wine. I have used Pointers in parse to link [Review], [Food] and [Wine] classes to a specific [Restaurant].

Example of [Food] table columns: [objectId(string)], [createdAt(date)] ... [name(string)], [price(number)], [restaurantObjectId(Pointer)]

Question: Is there a way to write a single parse query, to return a restaurant with all of its foods, wines and reviews?

Currently the only way I can figure out is to do three separate queries on each child table "where restaurantId = "

Upvotes: 0

Views: 30

Answers (1)

Wain
Wain

Reputation: 119031

You can't do it in one request. You can only get multiple different object types by including pointers, but your pointers are at the other end of the relationship (effectively).

To minimise network requests you can write a cloud function which gets the content you want for a restaurant, but it will still use multiple parse requests.

Upvotes: 1

Related Questions