包括自己的帖子以及来自关注用户的帖子

时间:2020-02-21 05:43:56

标签: gremlin gremlinpython

我想从用户的帖子中获取所有帖子以及我自己的帖子,以创建新闻提要。

g.V().has('name', 'Bob').both('is_friend').out('has_posted').as('posts')

上面的代码仅返回关注的用户的帖子。

我如何包含自己的帖子?

1 个答案:

答案 0 :(得分:0)

您可以使用unionidentity步骤:

g.V().has('name', 'Bob').union(
    both('is_friend'),
    identity())
    .out('has_posted').as('posts')

您可以看到问题的“实时”示例here(只需运行查询)