[英]Unable to add edge properties in Neptune/Gremlin?
I've been trying to add edges to existing vertices and give them a specific ID and some properties using the Gremlin library in nodeJS (connecting to an AWS Neptune graph) However, even though it seems as if the edges are created, the ID and properties were completely missed.我一直在尝试向现有顶点添加边,并使用 nodeJS 中的 Gremlin 库(连接到 AWS Neptune 图)为它们提供特定的 ID 和一些属性但是,即使看起来好像创建了边,ID 和完全错过了属性。 Also I'll explain what I'm trying to achieve so the gremlin query will be clearer: Edges have 3 properties: Hidden, Directed, and ModificationDateTime.此外,我还将解释我要实现的目标,以便 gremlin 查询更加清晰:边具有 3 个属性:Hidden、Directed 和 ModificationDateTime。
of course if there is a better way to do what I tried I would love to know and make it prettier!当然,如果有更好的方法来做我尝试过的事情,我很想知道并让它更漂亮!
I should mention that I am adding multiple edges with the same queries, meaning the following query is appended to itself (without the starting 'g') for each edge created.我应该提到我正在添加具有相同查询的多个边,这意味着对于创建的每个边,以下查询将附加到自身(没有起始“g”)。
` `
g
.V(`${pointA}`) // find the vertex with the given ID
.bothE(`${label}`) // find all edges with the given label
.where(__.otherV().hasId(`${pointB}`)) // find the edge with the given label that point to the given vertex
.fold()
.coalesce(
__.unfold().where(__.values('ModificationDateTime').is(gt(`${ignoreIfAboveDateTime}`))), // if there is an edge with the given label that points to the given vertex, and the edge's ModificationDateTime is greater than the given ignoreIfAboveDateTime, then do nothing
__.coalesce(
__.unfold(), // the edge exists, so it will only be updated
__.V(`${pointA}`).addE(`${label}`).to(__.V(`${pointB}`)).property(id, `${id}`) // the edge doesn't exist, so it will be created
)
.property('Hidden', `${hidden}`)
.property('Directed', `${directed}`)
.property('ModificationDateTime', `${modificationDateTime}`)
)
` `
When getting the edges the results are (for a single edge): { id:'82c27123-b690-296d-2266-24f377334c13' inV: v[056a3511-45ca-4e7c-838c-b144598ae0e54294967296] label: 'EdgesTestLabel123' outV: v[87fc214b-7066-460e-8660-c0ef19344a6b4294967296] properties: {} }
当获取边缘时,结果是(对于单个边缘): { id:'82c27123-b690-296d-2266-24f377334c13' inV: v[056a3511-45ca-4e7c-838c-b144598ae0e54294967296] label: 'EdgesTestLabel123' outV: v[87fc214b-7066-460e-8660-c0ef19344a6b4294967296] properties: {} }
Will appreciate any tip regarding this, thanks: :)将不胜感激有关此的任何提示,谢谢::)
I made a stupid我做了个蠢货
It works just fine, I just assumed that the "properties" returned are the actual properties of the edge but they weren't.它工作得很好,我只是假设返回的“属性”是边缘的实际属性,但事实并非如此。 when I got the edges with valueMap() everything was there, oh well当我用 valueMap() 得到边缘时,一切都在那里,哦,好吧
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.