如何找到 embeddedset 包含值 'x' 的边?

How do I find edges whose embeddedset contains the value 'x'?

我有以下图结构:

CREATE CLASS Role EXTENDS V;
CREATE CLASS Resource EXTENDS V;
CREATE CLASS is_allowed EXTENDS E;
CREATE PROPERTY is_allowed.actions EMBEDDEDSET STRING;

CREATE EDGE is_allowed FROM #19:1 TO #22:33 CONTENT {'actions':['read', 'write', 'execute']}

我现在正在尝试查找具有特定权限的对象,所以我尝试了:

SELECT inE('is_allowed')['read' in actions)] FROM Resource WHERE name = 'Some Resource'
SELECT expand(inE('is_allowed')[actions contains 'read']) FROM Resource
SELECT expand(inE('is_allowed')['read'=actions]) FROM Resource

但没有得到结果,我做了完整性检查:

SELECT expand(inE('is_allowed')) FROM Resource

我确实得到了两个显示入站边缘的结果。

我查看了这个 SO answer (OrientDB Query by edge property),当它是单个字符串属性时可以轻松过滤边缘,但不确定是否可能或如何在使用嵌入式集时进行过滤。

您可以尝试嵌套 SELECT 语句:

select from (
    SELECT expand(inE('is_allowed')) FROM Resource
  ) where actions contains "write"

编辑: 如果您需要角色或资源,您可以扩展进出。

角色:

select expand(out) from (
    SELECT expand(inE('is_allowed')) FROM Resource
  ) where actions contains "read"

以及资源:

select expand(in) from (
    SELECT expand(inE('is_allowed')) FROM Resource
  ) where actions contains "read"

再见