在 Neptune DB(Gremlin) 中创建顶点时如何跳过 Null 属性
How toSkip Null Property When Creating Vertex in NeptuneDB(Gremlin)
在 NeptuneDB 中,我想检查一个特定的顶点是否存在,如果不存在,则创建它并添加一些属性。
这是我在 Gremlin Python:
中的实现
g.V().hasLabel('Event').has(T.id, idNum).fold().coalesce(unfold(), addV('Event').property(T.id, idNum)). property(Cardinality.single, 'semState', event['semState']).property(Cardinality.single, 'System', systemname).next()
但有时 'System' 属性 可以为空,在这种情况下,会引发错误。所以我想知道是否有一种方法可以检查上面的查询中 'System' 是否为 null,如果为 null,则跳过它。
Gremlin 不喜欢空值,所以解决方案应该在客户端,通过拆分查询:
query = g.V().hasLabel('Event').has(T.id, idNum).fold().coalesce(unfold(), addV('Event').property(T.id, idNum)). property(Cardinality.single, 'semState', event['semState'])
if systemname is not None:
query = query.property(Cardinality.single, 'System', systemname)
query.next()
在 NeptuneDB 中,我想检查一个特定的顶点是否存在,如果不存在,则创建它并添加一些属性。 这是我在 Gremlin Python:
中的实现g.V().hasLabel('Event').has(T.id, idNum).fold().coalesce(unfold(), addV('Event').property(T.id, idNum)). property(Cardinality.single, 'semState', event['semState']).property(Cardinality.single, 'System', systemname).next()
但有时 'System' 属性 可以为空,在这种情况下,会引发错误。所以我想知道是否有一种方法可以检查上面的查询中 'System' 是否为 null,如果为 null,则跳过它。
Gremlin 不喜欢空值,所以解决方案应该在客户端,通过拆分查询:
query = g.V().hasLabel('Event').has(T.id, idNum).fold().coalesce(unfold(), addV('Event').property(T.id, idNum)). property(Cardinality.single, 'semState', event['semState'])
if systemname is not None:
query = query.property(Cardinality.single, 'System', systemname)
query.next()