后退和深度查询 [英] Backand deep querying

查看:125
本文介绍了后退和深度查询的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道是否可以检索对象在Backand中保存的对象集合。

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

例如 - 你有一个对象'Trip'与目的地有一对多关系的旅行可以有很多目的地。对象'Trip'中的属性'destination'是一个集合。

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.

在查询Trip对象时,我是否有可能收到Trip对象具有的一组Destination对象?

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 / objects / Trip)时无法获取有关集合对象的信息(目的地),所以你需要为它创建一个查询:

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

查询将返回所有Trip id(s),您可以为每个Trip循环并发出特定的API请求。要获取目的地的集合,请使用deep = true,如下所示:

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

依赖于您的客户端UI,您可以使用Promise执行上面的代码并使其成为延迟加载。您可以创建一个按需操作并在服务器上运行循环并立即返回包含所有数据的JSON。

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.

这篇关于后退和深度查询的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆