Overwrite means to update or clear values of properties other than UUID and ID; properties carried in the data will be updated, while those are not will be left as an empty string, null or 0 based on their data type.
Overwriting will insert or overwrite one or multiple nodes/edges in the current GraphSet:
- Overwrite nodes: the operation overwrites the data record when specifying either a UUID or an ID that already exists in the GraphSet, or when specifying a UUID-ID pair that exists and obeys the mapping relationship; the operation fails when specifying a UUID-ID pair that violates the mapping relationship in the GraphSet; the operation inserts the data record when specifying a UUID or an ID or a UUID-ID pair that does not exist in the GraphSet, or when not specifying any of them at all.
- Overwrite edges: the operation overwrites the data record when specifing a UUID that already exists in the GraphSet; the operation inserts the data record when specifying a UUID that does not exist in the GraphSet, or when not specifying the UUID; the operation fails when the start/end node of edge is not included or not existent.
It is not suggested to execute overwriting operation after streaming return of an algorithm, see details on
stream()
in document Ultipa Graph Analytics & Algorithms - Using Algorithms - Execution Method.
Syntax:
- Statement alias supported (NODE or EDGE type)
// To overwrite nodes of a certain schema in the current graphset
insert().overwrite().into(@<schema>)
.nodes([ // Square brackets can be omitted if overwrites only one node
{<property1>:<value1>, <property2>:<value2>, ...},
{<property1>:<value1>, <property2>:<value2>, ...},
...
])
// To overwrite edges of a certain schema in the current graphset, must carry _from and _to, or must carry _from_uuid and _to_uuid
insert().overwrite().into(@<schema>)
.edges([ // Square brackets can be omitted if overwrites only one edge
{<property1>:<value1>, <property2>:<value2>, ...},
{<property1>:<value1>, <property2>:<value2>, ...},
...
])
Example: Given an account U001 named "test", overwrite the account if it already exists, otherwise insert the account; check the account information after the operation
insert().overwrite().into(@account)
.nodes({_id: "U001", name: "test"}) as nodes
return nodes{*}
Example: Overwrite transaction edge of UUID = 1 with transaction No. TRX001 and from C001 to C003, or insert such an edge if not existing; insert another transaction edge with No. TRX003 and from C003 to C001 in the same UQL
insert().overwrite().into(@transaction)
.edges([
{no: "TRX001", _from: "C001", _to: "C003", _uuid: 1},
{no: "TRX003", _from: "C003", _to: "C001"}
])