gremlin - 包括自己的帖子和来自关注用户的帖子
问题描述
我想从用户的所有帖子中获取所有帖子以及我自己的帖子以创建新闻提要。
g.V().has('name', 'Bob').both('is_friend').out('has_posted').as('posts')
上面的代码只返回关注用户的帖子。
如何包含我自己的帖子?
解决方案
您可以使用union
和identity
步骤:
g.V().has('name', 'Bob').union(
both('is_friend'),
identity())
.out('has_posted').as('posts')
您可以在此处查看您的问题的“实时”示例(只需运行您的查询)
推荐阅读
- java - Java groupingBy:使用单个 Stream 获取两个(或更多)组
- google-cloud-platform - 尝试从 Apache Beam 访问 Google Cloud Storage 时出现 HttpForbiddenError
- regex - GA 不支持正则表达式
- ios - iOS 应用程序中的白标字体
- css - 为什么使用 css calc 函数计算复杂表达式不起作用?
- android - 更新 React Native(至 0.59.10)后,Assemble Release 构建失败
- html - 图像半透明
- r - 将数据从 .txt 文件导入 R
- node.js - 从 NodeJS 返回一个文件数组
- php - MySQL如何合并重复记录