PouchDB Delete Attachment
The removeAttachment() method is used to delete an attachment from PouchDB. You have to pass the document_id, attachment_id and _rev value with this method to delete attachmet. This method also accepts an optional callback function.
Delete Attachment Example
We have a document in PouchDB with id 002, which contains id, name, age, designation of an employee with attachment.
Let's remove the attachment by using removeAttachment() method.
Attachment is deleted successfully.
You can verify that the attachment is deleted from the document by using read command.
Delete Attachment from a Remote Database
You can delete an attachment from a remotely stored server (CouchDB). You just have to pass the path to the database in CouchDB, which contains the document that contains the attachment.
We have a database name "employees" stored on the CouchDB server.
The database "employees" has a document having id "001".
Let's delete the attachment.
Now you can see that the attachment is deleted.