create_document | Create a document; fails if its _id already exists. Arguments: dataset (string); document (object: _type string required — a schema type of the project, e.g. “post”; _id optional string, generated when omitted, “drafts.<id>” creates a draft instead of a published document; every other key is a field of that type, e.g. {“_type”:“post”,“title”:“Hello”,“slug”:{“_type”:“slug”,“current”:“hello”}}; a reference is {“_type”:“reference”,“_ref”:“<document id>”}); returnDocuments (optional boolean, true returns the full saved documents); dryRun (optional boolean, true validates without writing); autoGenerateArrayKeys (optional boolean, true adds the _key every array item of objects needs). |
create_or_replace_document | Create a document, or REPLACE it entirely when its _id exists (fields left out are removed — read it with get_document first to keep them). Arguments: dataset (string); document (object: _id string required, _type string required, every other key is a field, same shape as create_document); returnDocuments (optional boolean, true returns the full saved documents); dryRun (optional boolean, true validates without writing); autoGenerateArrayKeys (optional boolean, true adds the _key every array item of objects needs). |
patch_document | Modify fields of ONE existing document, identified by id (fails if it does not exist). Operations run in this order, at least one required: set (optional object, field path → new value, e.g. {“title”:“New”,“author.name”:“Ada”}); setIfMissing (optional object, same shape, only for absent fields); unset (optional array of field-path strings to remove, e.g. [“subtitle”]); inc / dec (optional objects, field path → number to add / subtract, e.g. {“views”:1}). Arguments: dataset (string); id (string — patching “post-123” changes the PUBLISHED document, “drafts.post-123” its draft); ifRevisionID (optional string, the _rev you read: the patch fails if the document changed since); returnDocuments (optional boolean, true returns the full saved documents); dryRun (optional boolean, true validates without writing); autoGenerateArrayKeys (optional boolean, true adds the _key every array item of objects needs). |