The insert().overwrite().into() clause facilitates either the overwriting of existing nodes or edges within a single schema or the insertion of new nodes or edges.
Syntax// Overwrite or insert nodes insert().overwrite().into(@<schema>).nodes([ {<property1>: <value1>, <property2>: <value2>, ...}, {<property1>: <value1>, <property2>: <value2>, ...} ]) // Overwrite or insert edges insert().overwrite().into(@<schema>).edges([ {<property1>: <value1>, <property2>: <value2>, ...}, {<property1>: <value1>, <property2>: <value2>, ...} ])
into() method.nodes() or edges() method.
{ }.[ ] can be omitted.When a node or edge is overwritten:
_id and/or _uuid. A targeted edge is specified by its _uuid, _from and _to (or _from_uuid and _to_uuid)null._id, _uuid, _from, _to, _from_uuid, _to_uuid) remain unchanged.A new node is inserted when new _id or _uuid is provided, or when both _id and _uuid are missing.
A new edge is inserted when new _uuid is provided, or when _uuid is missing.

Run these UQLs row by row in an empty graphset to create this graph:
UQLcreate().node_schema("user").edge_schema("follow") create().node_property(@user, "name").node_property(@user, "age", int32).edge_property(@follow, "time", datetime)Click to expand
UQLinsert().overwrite().into(@user).nodes([ {_id: "U001", name: "John"}, {_id: "U005", name: "Alice"}, {age: 12} ]) as n return n{*}
_id U001 exists in the graph, so it is overwritten._id U005 does not exist in the graph._id and _uuid are missing.Result:
_id | _uuid | name | age |
|---|---|---|---|
| U001 | 1 | John | null |
| U005 | 5 | Alice | null |
| ULTIPA8000000000000006 | 6 | null | 12 |
UQLinsert().overwrite().into(@follow).edges([ {_uuid: 1, _from: "U004", _to: "U001"}, {_uuid: 4, _from: "U002", _to: "U003"}, {_from: "U002", _to: "U001", time: "2023-9-6"} ]) as e return e{*}
_uuid 1, _from U004, and _to U001 exists in the graph, so it's overwritten._uuid 4 does not exist in the graph._uuid is missing.Result:
| _uuid | _from | _to | _from_uuid | _to_uuid | time |
|---|---|---|---|---|---|
| 1 | U004 | U001 | 4 | 1 | null |
| 4 | U002 | U003 | 2 | 3 | null |
| 5 | U002 | U001 | 2 | 1 | 2023-09-06 00:00:00 |
_id and _uuid are provided, one of their values exists in the graph while the other one does not._id and _uuid are provided, they both exist in the graph but they don't match._uuid does not match the given start and end nodes.