PouchDB Delete AttachmentThe 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. Syntax: Delete Attachment ExampleWe 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. Save the above code in a file named "Delete_Attachment.js" within a folder name "PouchDB_Examples". Open the command prompt and execute the JavaScript file using node: Output: Attachment is deleted successfully. VerificationYou can verify that the attachment is deleted from the document by using read command. Delete Attachment from a Remote DatabaseYou 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. ExampleWe have a database name "employees" stored on the CouchDB server. The database "employees" has a document having id "001". Let's delete the attachment. Save the above code in a file named "Delete_Remote_Attachment.js" within a folder name "PouchDB_Examples". Open the command prompt and execute the JavaScript file using node: Output: VerificationNow you can see that the attachment is deleted. Next TopicPouchDB Replication |