{% include anchor.html title="Fetch a document" hash="fetch_document"%} {% highlight js %} db.get(docId, [options], [callback]) {% endhighlight %} Retrieves a document, specified by `docId`. ### Options All options default to `false` unless otherwise specified. * `options.rev`: Fetch specific revision of a document. Defaults to winning revision (see [the CouchDB guide](http://guide.couchdb.org/draft/conflicts.html)). * `options.revs`: Include revision history of the document. * `options.revs_info`: Include a list of revisions of the document, and their availability. * `options.open_revs`: Fetch all leaf revisions if `open_revs="all"` or fetch all leaf revisions specified in `open_revs` array. Leaves will be returned in the same order as specified in input array. * `options.conflicts`: If specified, conflicting leaf revisions will be attached in `_conflicts` array. * `options.attachments`: Include attachment data. * `options.local_seq` (*DEPRECATED*): Include sequence number of the revision in the database, this will be removed in the next major version. * `options.ajax`: An object of options to be sent to the ajax requester. In Node they are sent verbatim to [request][] with the exception of: * `options.ajax.cache`: Appends a random string to the end of all HTTP GET requests to avoid them being cached on IE. Set this to `true` to prevent this happening. #### Example Usage: {% include code/start.html id="get1" type="callback" %} {% highlight js %} db.get('mydoc', function(err, doc) { if (err) { return console.log(err); } // handle doc }); {% endhighlight %} {% include code/end.html %} {% include code/start.html id="get1" type="promise" %} {% highlight js %} db.get('mydoc').then(function (doc) { // handle doc }).catch(function (err) { console.log(err); }); {% endhighlight %} {% include code/end.html %} #### Example Response: {% highlight js %} { "_id": "mydoc", "_rev": "1-A6157A5EA545C99B00FF904EEF05FD9F" "title": "Rock and Roll Heart", } {% endhighlight %} The response contains the document as it is stored in the database, along with its `_id` and `_rev`.