Updates edge records in the current database. This is the equivalent of the
UPDATE command, with the addition of checking and maintaining graph consistency with vertices, in the event that you update the
Bear in mind that OrientDB can also work in schema-less mode, allowing you to create fields on the fly. Furthermore, that it works on collections and necessarily includes some extensions to the standard SQL for handling collections.
This command was introduced in version 2.2.
UPDATE EDGE <edge> [SET|INCREMENT|ADD|REMOVE|PUT <field-name> = <field-value>[,]*]|[CONTENT|MERGE <JSON>] [UPSERT] [RETURN <returning> [<returning-expression>]] [WHERE <conditions>] [LOCK default|record] [LIMIT <max-records>] [TIMEOUT <timeout>]
<edge>Defines the edge that you want to update. You can choose between:
- Class Updating edges by class.
- Cluster Updating edges by cluster, using
- Record ID Updating edges by Record ID.
SETUpdates the field to the given value.
REMOVEDefines an item to remove from a collection of fields.
RETURNDefines the expression you want to return after running the update.
COUNTReturns the number of updated records. This is the default operator.
BEFOREReturns the records before the update.
AFTERReturns the records after the update.
WHEREDefines the filter conditions.
LOCKDefines how the record locks between the load and update. You can choose between the following lock strategies:
DEFAULTDisables locking. Use this in the event of concurrent updates. It throws an exception in the event of conflict.
RECORDLocks the record during the update.
UPSERTUpdates a record if it exists or inserts a new record if it doesn't. This avoids the need to execute two commands, (one for each condition, inserting and updating).
LIMITDefines the maximum number of records to update.
Change the edge endpoint:
UPDATE EDGE Friend SET out = (SELECT FROM Person WHERE name = 'John') WHERE foo = 'bar'
UPSERT clause only guarantees atomicity when you use a
UNIQUE index and perform the look-up on the index through the
UPDATE EDGE hasAssignee FROM ( SELECT FROM Project WHERE id=:id ) TO ( SELECT FROM User WHERE login in :login ) UPSERT WHERE hasAssignee.id = 56
Here, you must have a unique index on
hasAssignee.id to guarantee uniqueness on concurrent operations.
For more information, see