Please note, this is a STATIC archive of website www.javatpoint.com from 19 Jul 2022, cach3.com does not collect or store any user information, there is no "phishing" involved.
Javatpoint Logo
Javatpoint Logo

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.

Syntax:


Delete Attachment Example

We have a document in PouchDB with id 002, which contains id, name, age, designation of an employee with attachment.

PouchDB Delete attachent 1

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:

PouchDB Delete attachent 2

Attachment is deleted successfully.


Verification

You can verify that the attachment is deleted from the document by using read command.

PouchDB Delete attachent 3

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.

Example

We have a database name "employees" stored on the CouchDB server.

PouchDB Delete attachent 4

The database "employees" has a document having id "001".

PouchDB Delete attachent 5

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:

PouchDB Delete attachent 6

Verification

Now you can see that the attachment is deleted.






Youtube For Videos Join Our Youtube Channel: Join Now

Feedback


Help Others, Please Share

facebook twitter pinterest

Learn Latest Tutorials


Preparation


Trending Technologies


B.Tech / MCA