通过查询检索关系的属性

Retrieving properties of relationship through query

我想创建一个查询,其中 returns 容器(资产)所有者的 ID 等于参数的所有请求(资产)。

模型文件(容器所有者是公司参与者,通过id标识):

namespace org.acme.shipping.assets
import org.acme.shipping.participants.*

asset Container identified by number {
  o String number
  o ContainerType type
  o String content
  o ContainerStatus status default = "FREE"
  --> Company owner
}

enum ContainerType {
  o DRY
  o REEFER
}

enum ContainerStatus {
  o LOCKED
  o FREE
}

asset Request identified by id {
  o String id
  --> Container container
}

查询文件

query getRequestsByCompany {
  description: "Get requests by company"
  statement:
      SELECT org.acme.shipping.assets.Request
          WHERE (container.owner.id == _$company_id)
}

但是,当前的查询似乎不起作用。这可以通过查询实现吗?

我也做了很多研究,也想用查询文件来做,但找不到办法,所以我认为目前不可能。

另一种方法是使用环回过滤器:

类似于:

{"where":{"shipmentId":1000}, "include":"resolve"}

您可以在喜欢按数字搜索中进入一个级别。如果得到确切的解决方案,我正在努力。

query getRequestsByCompany {
  description: "Get requests by company"
  statement:
      SELECT org.acme.shipping.assets.Request
          WHERE (container == _$container)
      }