Backand deep querying

怎甘沉沦 提交于 2019-12-22 11:19:05

问题


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 ?


回答1:


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.



来源:https://stackoverflow.com/questions/36441873/backand-deep-querying

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!