[英]Gremlin - select a vertex, create new vertices and edges in single query
I have a user vertex already created.我已经创建了一个用户顶点。
g.V().has('user','username','vipul').as('user')
I want to create a new 'group' vertex with some properties and also a new 'options' vertex with some other properties.我想创建一个具有某些属性的新“组”顶点,以及一个具有其他一些属性的新“选项”顶点。
g.addV(label,'group','group_name','DC11').as('group')
g.addV(label,'options','command_line_arguments','-D -n').as('options')
Now I want to create an edge from user to group and another edge from group to options.现在我想创建一条从用户到组的边,以及从组到选项的另一条边。
user ---> group, group ---> options
Can these queries be combined, selecting a vertex, creating new vertices and then creating new edges?是否可以组合这些查询,选择一个顶点,创建新顶点,然后创建新边?
You can simply chain the steps together:您可以简单地将这些步骤链接在一起:
g.V().has('user','username','vipul').as('user').
addV('group').property('group_name','DC11').as('group').
addE('memberOfGroup').from('user').
addV('options').property('command_line_arguments','-D -n').
addE('hasOptions').from('group')
Note that I set the properties with the property
step as I prefer that form, but you can also add them directly with the addV
step.请注意,我使用property
步骤设置属性,因为我更喜欢该表单,但您也可以使用addV
步骤直接添加它们。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.