Update, upsert, delete
Update writes every property of the node object back. It does not change relations: use the
methods of chapter 14 for those.
venue.Capacity = 1800;
db.Update(venue); // skips the write when nothing changed
db.Upsert(venue); // inserts, or updates when the id exists
db.UpdateIfExists(venue); // does nothing when the node is gone
db.ForceUpdate(venue); // writes without comparing first
db.UpdateProperty(venue, v => v.Capacity, 1800); // one property, leaving the others alone
db.AddToProperty(venue, v => v.Capacity, 50); // read, add and write in one atomic step
db.Delete(venueId); // also removes the node's relations
db.DeleteIfExists(venueId);
db.Delete(new[] { id1, id2 });The variants follow one naming rule across the API:
| Name | Behaviour |
|---|---|
no suffix, …OrFail |
throws when the node is missing, or already there for an insert |
…IfExists, …IfNotExists |
does nothing in that case |
Force… |
writes without comparing with the stored node first |
Each call is a transaction of its own (chapter 15). By default it returns once the
change is in the log buffer. Pass flushToDisk: true to wait until it is on disk.