create class User extends V
create class Post extends V
create class Posted extends E
create vertex User set name = 'user1'
create vertex User set name = 'user2'
create vertex Post set name = 'post0'
create vertex Post set name = 'post1'
create vertex Post set name = 'post2'
create edge Posted from (select from Post where name = 'post0') to (select from User where name = 'user1')
create edge Posted from (select from Post where name = 'post1') to (select from User where name = 'user1')
create edge Posted from (select from Post where name = 'post2') to (select from User where name = 'user2')
如果你有類似上述的東西,和例如,你想知道的不是USER1相關的所有帖子(這將是POST2)。假設記錄ID爲用戶1是#12:0。
您可以:
select from Post where #12:0 not in out('Posted')
// or
select expand(in('Posted')) from (select from User where @rid not in [#12:0])
輸出:
UPDATE
您也可以使用用戶的名稱,而不是它的@rid:
select * from Post where $record_id.rid[0] not in out('Posted')
let $record_id = (select @rid from User where name = 'user1')
但要注意的是,讓子句爲每後執行一次(在這種情況下,3次)。這意味着當你有很多帖子時它不會很有效率。
在第一個例子中:我怎樣才能做到這一點,但我沒有@rid,我有用戶的名字來檢查? –
看到我上面的更新。 – vitorenesduarte