| {% include anchor.html edit="true" title="Delete an attachment" hash="delete_attachment" %} | |
| {% highlight js %} | |
| db.removeAttachment(docId, attachmentId, rev, [callback]) | |
| {% endhighlight %} | |
| Delete an attachment from a doc. You must supply the `rev` of the existing doc. | |
| #### Example Usage: | |
| {% include code/start.html id="delete_att" type="callback" %} | |
| {% highlight js %} | |
| var rev = '1-068E73F5B44FEC987B51354DFC772891'; | |
| db.removeAttachment('doc', 'att.txt', rev, function(err, res) { | |
| if (err) { return console.log(err); } | |
| // handle result | |
| }); | |
| {% endhighlight %} | |
| {% include code/end.html %} | |
| {% include code/start.html id="delete_att" type="async" %} | |
| {% highlight js %} | |
| try { | |
| var rev = '1-068E73F5B44FEC987B51354DFC772891'; | |
| var result = await db.removeAttachment('doc', 'att.txt', rev); | |
| } catch (err) { | |
| console.log(err); | |
| } | |
| {% endhighlight %} | |
| {% include code/end.html %} | |
| {% include code/start.html id="delete_att" type="promise" %} | |
| {% highlight js %} | |
| var rev = '1-068E73F5B44FEC987B51354DFC772891'; | |
| db.removeAttachment('doc', 'att.txt', rev).then(function (result) { | |
| // handle result | |
| }).catch(function (err) { | |
| console.log(err); | |
| }); | |
| {% endhighlight %} | |
| {% include code/end.html %} | |
| #### Example Response: | |
| {% highlight js %} | |
| { | |
| "ok": true, | |
| "rev": "2-1F983211AB87EFCCC980974DFC27382F" | |
| } | |
| {% endhighlight %} | |