Module edit
Expand description
Edits of a key’s state from outside its handlers.
An edit is an exclusive call to the reserved handler EDIT_HANDLER,
which every object type has: it waits for the key like any exclusive
call, and its changes commit with its result in the UpdateDone record
a handler’s writes make, so it replays, deduplicates by call ID and is
sealed by the codec as they are. The handler’s code in each SDK is one
call to the engine, which applies the edit below.
The edit is a JSON object, applied in this order:
| Field | |
|---|---|
ifVersion | refuse the edit unless the state’s version is this |
clearAll | true: empty the state |
clear | fields to remove (absent ones are ignored) |
set | fields to set, {field: value}; null removes one |
patch | a JSON Patch (RFC 6902) over the state as one JSON object |
by | who asked, recorded with the edit (the HTTP API and CLI set it) |
The answer is {"version": the new version, "changed": [fields]}.
Constants§
- EDIT_
HANDLER - The handler every object type has that applies an edit.
- STALE
- How the refusal of an edit whose
ifVersionis stale begins.
Functions§
- apply
- The changes
editmakes tostate(Noneremoves a field) and the edit’s answer. Changes nothing on a refusal. - patch
- Applies a JSON Patch (RFC 6902) to
doc: all of it, or none of it. - version
- The state’s version: a hash of its JSON, so an editor that read one
version can refuse to overwrite another (
ifVersion, HTTPIf-Match).