DEV Community

Muhammad Muneeb Ur Rehman
Muhammad Muneeb Ur Rehman

Posted on

Set or Update Edge Properties in Apache AGE

In this blog, I will tell you how you can set or update properties of an edge.
Firstly, in edge we have edge id, name (formally we call it label), end_id, start_id. These attributes of an edge got set when an edge is created. These properties cannot be changed.
Secondly, we can also have properties attribute that stores data related to the edge. The data is stored in key value pair, in properties attribute.

General Form:
SELECT * FROM cypher('graph_name', $$
MATCH (a:label_name)-[edge:edgeLabel_name]->(b:label_name)
SET edge.propertyName = any_Value
$$) as (edge agtype);

Explanation:
We get the desired edge by MATCH (a:label_name)-[edge:edgeLabel_name]->(b:label_name). We set the value in edge properties by using SET edge.propertyName = any_Value. If the propertyName already exists in the edge properties, it will get updated with the new value (any_Value). If the propertyName do not exists in the edge properties, it will create a new attribute propertyName in the properties of the edge with the value (any_Value).

For more details visit: https://age.apache.org/overview/

AGE Github Link: https://github.com/apache/age

AGE Viewer Github Link: https://github.com/apache/age-viewer

Top comments (0)