2

I want to know if it is possible to retrieve and the collection of objects that an object holds in Backand.

For example - you have an object 'Trip' which has a one-to-many relationship with 'Destination' as a trip can have many destinations. The attribute 'destination' in object 'Trip' is a collection.

Is it possible, when querying for a 'Trip' object, that I am able to receive the associated 'Destination' objects that the 'Trip' object has a collection of ?

Vince
  • 691
  • 1
  • 8
  • 18

1 Answers1

3

While getting the parent object (/1/objects/Trip) there is no way to get information on the collection object (Destination), so you need to create a query for it:

SELECT trip FROM Destination 
WHERE trip IS NOT NULL
group by trip

The query will return all the Trip id(s), which you can loop and make a specific API request for each Trip. To get the collection of the Destinations use deep=true, like this:

/1/objects/Trip/1?deep=true

Depend on you client UI, you can do the code above and make it a Lazy load using Promise. You could create an on-demand action and run the loop on the server and return a JSON with all the data at once.

Itay
  • 734
  • 4
  • 5