Gremlin Javascript 折叠、合并和展开

iRy*_*ell 2 javascript gremlin

使用 gremlin-javascript,我想执行“如果不存在则添加”事务,例如:

g.V()
  .hasLabel('account').has('uid', '1')
  .fold()
  .coalesce(
    g.V().unfold(),
    g.V().addV('account').property('uid', '1')
  )
Run Code Online (Sandbox Code Playgroud)

我将如何表达这种查询?

use*_*828 5

更明确地说:

const __ = gremlin.process.statics;

g.V()
  .hasLabel('account').has('uid', '1')
  .fold()
  .coalesce(
    __.unfold(),
    __.addV('account').property('uid', '1')
  )
Run Code Online (Sandbox Code Playgroud)