如何在OrientDB中编写具有OR
条件的匹配项?
EG:我想查找用户具有accessTo
的文件以及组用户所属的文件可以访问的文件。
select from (
MATCH
{class: user, where:(userid='User1'), as: u},
{as:u}-accessTo->{class: so,where:(projectId='Project1'), as: r},
{as:u}-memberOf->{class: group, where:(projectId='Project1')}-accessTo->
{class: so,as: r}
RETURN r)
答案 0 :(得分:0)
当前,MATCH语句中没有OR选项,因此您必须使用两个查询和一个unionAll:
select unionAll($a, $b)
LET
$a = (MATCH
{class: user, where:(userid='User1'), as: u},
{as:u}-accessTo->{class: so,where:(projectId='Project1'), as: r},
RETURN r),
$b = (MATCH
{class: user, where:(userid='User1'), as: u},
{as:u}-memberOf->{class: group, where:(projectId='Project1')}-accessTo->
{class: so,as: r}
RETURN r),
)