json
set
Set a JSON value at a document path, creating the document when missing.
strata json setdb.json.set(key: 'str', path: 'str', value: 'Any') -> 'Any'wire json_set
Writes a JSON value at a path inside a document, creating the document and any missing intermediate objects when needed. Setting the root path `$` replaces the whole document; setting a nested path like `$.profile.name` updates one field and records a new document version.
Successful mutations return an acknowledgement of the outcome: for a state-changing write, the affected target with the mutation effect and commit facts; for mutations that produce a domain result (such as a branch or a promotion outcome), that result object.
To see the complete help for this command, run:
strata json set --helphelp(db.json.set)
Example
Store a JSON document, then read it back.
strata json set user $ {"age":30,"name":"alice"}strata json get user $
_ = db.json.set("user", "$", {"name": "alice", "age": 30})db.json.get("user", "$")
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
| key | string | yes | Document key. |
| path | string | yes | JSON path. |
| value | any | yes | JSON value. |
| branch | string or null | no | Target branch. Defaults to the executor handle branch. |
| space | string or null | no | Target product space. Defaults to `"default"`. |
Returns
MutationAck<JsonWrite>
- dataobject
- typestring
Errors
Recover by code. Retry policy and commit outcome come from the shipped error registry.
| Code | Retry | Commit outcome |
|---|---|---|
| failed_precondition.engine.runtime_closed | never | not_started |
| not_found.engine.branch | never | not_applicable |
| invalid_argument.engine.product_space | never | not_started |
| invalid_argument.engine.json_document_id | never | not_started |
| invalid_argument.engine.json_path | never | not_started |
| invalid_argument.engine.json_path_too_long | never | not_started |
| invalid_argument.engine.json_path_not_found | never | not_started |
| invalid_argument.engine.json_path_type | never | not_started |
| invalid_argument.engine.json_value | never | not_started |
| invalid_argument.engine.json_document_too_large | never | not_started |
| invalid_argument.engine.json_document_too_deep | never | not_started |
| invalid_argument.engine.json_array_too_large | never | not_started |