The document ID can be specified by including the
_id
field in the JSON of the submitted
record. The following request will create the same document with
the ID FishStew
:
POST http://couchdb:5984/recipes/ Content-Type: application/json { "_id" : "FishStew", "servings" : 4, "subtitle" : "Delicious with fresh bread", "title" : "Fish Stew" }
The structure of the submitted document is as shown in the table below:
Table 6.2. CouchDB Document
Field | Description |
_id (optional) | Document ID |
_rev (optional) | Revision ID (when updating an existing document) |
In either case, the returned JSON will specify the document ID, revision ID, and status message:
{ "id" : "FishStew", "ok" : true, "rev" : "1-9c65296036141e575d32ba9c034dd3ee" }