Skip to content

Commit 6f1a750

Browse files
authoredJun 13, 2022
Cross-links info on getting attachments with their document (#299)
1 parent f5a731c commit 6f1a750

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed
 

‎README.md

+10-2
Original file line numberDiff line numberDiff line change
@@ -545,12 +545,20 @@ Gets a document from CouchDB whose `_id` is `docname`:
545545
const doc = await alice.get('rabbit')
546546
```
547547

548-
or with optional query string `params`:
548+
or with optional [query string `params`](https://docs.couchdb.org/en/stable/api/document/common.html#get--db-docid):
549549

550550
```js
551551
const doc = await alice.get('rabbit', { revs_info: true })
552552
```
553553

554+
If you pass `attachments=true`, the `doc._attachments.attachmentNameN.data` fields will contain the
555+
[base-64 encoded attachments](https://docs.couchdb.org/en/stable/json-structure.html#document-with-attachments).
556+
Or, you can use [`db.multipart.get`](https://github.com/DougReeder/couchdb-nano#dbmultipartgetdocname-params-callback)
557+
and parse the returned buffer to get the document and attachments.
558+
559+
See the [attachments methods](https://github.com/apache/couchdb-nano#attachments-functions) to retrieve
560+
*just* an attachment.
561+
554562
### db.head(docname, [callback])
555563

556564
Same as `get` but lightweight version that returns headers only:
@@ -957,7 +965,7 @@ fs.readFile('rabbit.png', (err, data) => {
957965
958966
### db.multipart.get(docname, [params], [callback])
959967
960-
Get `docname` together with its attachments via `multipart/related` request with optional query string additions `params`. The multipart response body is a `Buffer`.
968+
Get `docname` together with its attachments via `multipart/related` request with optional [query string additions](https://docs.couchdb.org/en/stable/api/document/common.html#get--db-docid). The multipart response body is a `Buffer`.
961969
962970
```js
963971
const response = await alice.multipart.get('rabbit')

0 commit comments

Comments
 (0)
Please sign in to comment.