RedisGraph / redisgraph-go

A Golang client for redisgraph
https://redisgraph.io
BSD 3-Clause "New" or "Revised" License
132 stars 38 forks source link

Adding edges to existing nodes #36

Open tradetree opened 3 years ago

tradetree commented 3 years ago

My development team noticed that there is no way in redisgraph-go to add edges to existing nodes without duplicating the nodes in the process. Please see https://github.com/RedisGraph/redisgraph-py/issues/16 as a reference to this issue within Redis graph in general. The solution described here points to using MATCH (f:%s{%s:'%s'}), (t:%s{%s:'%s'}) CREATE (f)-[:in]->(t) as the way to avoid duplication of nodes. However, we do not find a way within redisgraph-go to make such a transaction? There is basically no 'update' possible to nodes, only create and delete. We can delete old nodes and create new ones with edges, but this is costly and inefficient. Is there any plan to add an UpdateEdge or something similar as AddEdge duplicates nodes?

swilly22 commented 3 years ago

Hi @tradetree, Sorry for the confusion, but the Graph, Node and Edge object are primarily used for creating an initial graph, thus to introduce a new edge between two existing nodes please use the graph.query function and provide a query which located the nodes you wish to connect.

The ability you're asking for is more likely to be found in a OGM (Object Graph Mapping) type of a solution.

tradetree commented 3 years ago

Thanks for the info. We were able to use a query to add an edge between two existing nodes, but the concept of adding or updating relationships like edges this way is kind of confusing. Once objects are committed to a database it should be possible to update them, so I guess I'm just missing something. I searched on OGM via google and read what I could find, but it was only marginally helpful. They compare OGM to ORM, but while I understand ORM this does not quite fit in with that understanding. We are not mapping objects into the graph database, but trying to create objects directly and then update them. Anyway, it appears to make sense to you and there is no other method in redisgraph-go that would be better, so we'll stick to the query method.

swilly22 commented 3 years ago

@tradetree have you looked into https://github.com/cr0hn/sqerzo ?

tradetree commented 3 years ago

@tradetree have you looked into https://github.com/cr0hn/sqerzo ?

I will check it out, thanks! But we did get it working with the query method and we have our own mapping now.