Replace document
Replaces the document with key <key> with the one in the body, provided there is such a document and no precondition is violated.
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 body must 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 (depending on waitForSync, see below), the ETag header field contains the new revision of the document 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 each 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 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 replaced 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 replaced 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 replace a document based on a target revision id by using the if-match HTTP header.
Request body
Example request
{
"item1": "data1"
}Response
Successfully replaced documents 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.