Data update syntax
This topic describes the data update syntax.
Syntax
You can use Gremlin syntax to add, update, or delete node and edge data. When you add or update a node or an edge, you must specify all of its properties. To delete a node or an edge, you must specify its unique identifier.
Add a node
Format:
g("graph_name").addV("node_type").property("pkey", "node_id").property("property_name", "property_value")
References
g("tinkerpop").addV("person").property("pkey","11").property("name","Durant").property("age","34")
Note: The pkey property name cannot be changed. It represents the unique key of the node.
Update a node
Format:
g("graph_name").addV("node_type").property("pkey","node_ID").property("property_name","property_value")
Related information
g("tinkerpop").addV("person").property("pkey","11").property("name","Durant1").property("age","345")
Note: The pkey property name cannot be changed. It represents the unique key of the node.
Adding edge information
Format:
g("graph_name").addE("edge_type").property("pkey","source_node_ID").property("skey","destination_node_ID").property("property_name","property_value")
References
g("tinkerpop").addE("relation").property("pkey","11").property("skey","11").property("name","Durant")
.property("age","34")
Note: The pkey and skey property names cannot be changed.
Update an edge
Format:
g("graph_name").addE("edge_type").property("pkey","source_node_ID").property("skey","destination_node_ID").property("property_name","property_value")
References
g("tinkerpop").addE("relation").property("pkey","11").property("skey","11").property("name","Durant123")
.property("age","345")
Note: The pkey and skey property names cannot be changed.
Delete a node
Format:
g("specify_graph_name").V("specify_node_id").hasLabel("specify_node_type").drop()
References
g("your_graph_name").V("pk_value").hasLabel("your_label").drop()
Delete an edge
Format:
g("graph_name").E("edge_ID_value").hasLabel("edge_type").drop()
References
g("graph_name").E("pk1").hasLabel("label").drop()
Notes
For more information, see Notes.