Skip to content

UPDATE EDGE

The UPDATE EDGE statement updates properties on an edge. UPDATE EDGE supports compare-and-set (CAS).

Syntax

UPDATE EDGE ON <edge_type>
<src_vid> -> <dst_vid> [@<rank>]
SET <update_prop>
[WHEN <condition>]
[YIELD <output>]
Field Required Description Example
ON <edge_type> Yes Specifies the type of the edge. The properties to be updated must be on this edge type. ON serve
<src_vid> Yes Specifies the source vertex ID of the edge. "player100"
<dst_vid> Yes Specifies the destination vertex ID of the edge. "team204"
<rank> No Specifies the rank of the edge. 10
SET <update_prop> Yes Specifies the properties to be updated and how they will be updated. SET start_year = start_year +1
WHEN <condition> No Specifies the filter conditions. If <condition> evaluates to false, the SET clause does not take effect. WHEN end_year < 2010
YIELD <output> No Specifies the output format of the statement. YIELD start_year AS Start_Year

Example

// Check the properties of the edge with the GO statement.
nebula> GO FROM "player100" \
        OVER serve \
        YIELD serve.start_year, serve.end_year;
+------------------+----------------+
| serve.start_year | serve.end_year |
+------------------+----------------+
| 1997             | 2016           |
+------------------+----------------+

// Update the start_year property and return end_year and the new start_year.

nebula> UPDATE EDGE on serve "player100" -> "team204"@0 \
        SET start_year = start_year + 1 \
        WHEN end_year > 2010 \
        YIELD start_year, end_year;
+------------+----------+
| start_year | end_year |
+------------+----------+
| 1998       | 2016     |
+------------+----------+

Last update: May 10, 2021