Skip to main content

Module edit

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
ifVersionrefuse the edit unless the state’s version is this
clearAlltrue: empty the state
clearfields to remove (absent ones are ignored)
setfields to set, {field: value}; null removes one
patcha JSON Patch (RFC 6902) over the state as one JSON object
bywho 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 ifVersion is stale begins.

Functions§

apply
The changes edit makes to state (None removes 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, HTTP If-Match).