Documents

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.

put/_fabric/{fabric}/_api/document/{collection}/{key}

Request

Path parameters

fabricstring string required

The name of the fabric.

collectionstring string required

The name of the collection.

keystring string required

This URL parameter must be a document key.

Query parameters

ignoreRevsboolean

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.

returnOldboolean

If set to true, adds the old attribute which displays document revisions.

returnNewboolean

If set to true, adds the new documents to the new attribute.

silentboolean

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.

waitForSyncboolean

If set to true, returns only after data has been synced to disk.

Headers

If-Matchstring

You can conditionally replace a document based on a target revision id by using the if-match HTTP header.

Request body

object required

Example request

{
  "item1": "data1"
}

Response

Successfully replaced documents when waitForSync is enabled.

_idstring

ID of the collection.

_keystring

_key details of collection.

_revstring

_rev details of collection.

_oldRevstring

previous revision of collection.

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.