如何查询具有特定属性的相邻顶点?

How to query a neighbor vertex, which has certain attributes?

我正在使用 OrientDB 2.0。查询很简单,但我似乎无法弄明白。我有 2 个 classes:UserUserGroup。为了简单起见,User 只有 usernamepassword 属性,而 UserGroup 只有一个 id 属性。关系很简单:

User --- user_group --> UserGroup

其中 user_group 是连接 UserUserGroup 顶点的 class 边的名称。

我想要做的是获得一个具有特定用户名和密码的用户,其中 UserGroup.id 等于 group1

我目前拥有的是:

select expand(in('user_group')[username='foo' and password='bar']) 
from UserGroup
where id = 'group1'

但这对我不起作用。我做错了什么?

我想,经过几次尝试,我找到了答案:

select from 
   (select expand(in('user_group'))
    from UserGroup
    where id = 'group1')
where username='foo' and password='bar'

如果有人能提出更优雅的解决方案,那也很好

select 
from (
     select expand(in('user_group')) 
     from UserGroup 
     where id = 'group1'
) 
where username='foo' and password='bar'
create class User extends V
create property User.username string
create property User.password string

create class UserGroup extends V
create property UserGroup.id string

create class user_group extends E


create vertex User set username = 'foo', password = 'bar'
create vertex UserGroup set id = 'group1'

create edge user_group from (select from User where username = 'foo') to (select from UserGroup where id = 'group1')


select expand(in('user_group')[username='foo'][password='bar']) 
from UserGroup
where id = 'group1'