Update document
Partially updates the document identified by key. The body of the request must contain a JSON document with the attributes to patch (the patch document). All attributes from the patch document are added to the existing document if they do not yet exist, and overwritten in the existing document if they do exist there.
Setting an attribute value to null in the patch document causes a value of null to be saved for the attribute by default.
If the If-Match header is specified and the revision of the document in the database is unequal to the given revision, the precondition is violated.
If If-Match is not given and ignoreRevs is false, a _rev attribute in each document bodymust match the revision of the corresponding document in the database. Otherwise, the call fails.
If a precondition is violated, a HTTP 412 is returned.
If the document exists and can be updated, a HTTP 201 or a HTTP 202 is returned, the ETag header field contains the new revision of the document (in double quotes) and the Location header contains a URL under which the document can be queried.
If silent is set to false, the body of the response contains a JSON object with the information about the handle and the revision.
- _id contains the known document-handle of the updated document.
- _key contains the key that uniquely identifies a document.
- _rev contains the new document revision.
If the query parameter returnOld is true, the previous revision of the document is returned under the old attribute in the result.
If the query parameter returnNew is true, the new document is returned under the new attribute in the result.
If the document does not exist, a HTTP 404 is returned and the body of the response contains an error document.
Request
- The document declares no server URL.
- Auth
- API key in header Authorization
- or HTTP bearer
- TypeScriptA function with typed inputs. Its response is checked against the schema.
Path parameters
The name of the fabric.
The name of the collection.
This URL parameter must be a document key.
Query parameters
If the intention is to remove existing attributes with the patch command, the URL query parameter keepNull can be used with a value of false. This modifies the behavior of the patch command to remove any attributes from the existing document that are contained in the patch document with an attribute value of null.
Controls whether objects (not arrays) is merged if present in both the existing and the patch document. If set to false, the value in the patch document overwrites the existing document's value. If set to true, objects is merged. The default is true.
If set to true, the _rev attributes in the given document is ignored. If set to false, the _rev attribute given in the body document is taken as a precondition. The document is only updated if the current revision is the one specified.
If set to true, adds the old attribute which displays document revisions.
If set to true, adds the new documents to the new attribute.
If set to true, an empty object is returned as response. No meta-data is returned for the updated document. This option can be used to save some network traffic.
If set to true, returns only after data has been synced to disk.
Headers
You can conditionally update a document based on a target revision id by using the if-match HTTP header.
Request body
Example request
{
"_key": "key1",
"item1": "data1"
}Response
Successfully updated document when waitForSync is enabled.
Example response
{
"_id": "test/foo",
"_key": "foo",
"_rev": "_dPRuHxe--_",
"_oldRev": "_dP34awxe--_"
}Changes
No recorded changes to this operation across all 1 revision of this API.