我有以下图表结构:
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答案(OrientDB Query by edge property),并且可以在单个字符串属性时轻松过滤边缘,但不确定它是否可行或在使用嵌入式集时如何过滤
答案 0 :(得分:3)
您可以尝试嵌套的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"
BYE