An attachment can be deleted from PouchDB using the removeAttachment() method.
Following is the syntax of the removeAttachment() method. To this method, we have to pass the document id, attachment id, and _rev value. This method also accepts an optional callback function.
Suppose there is a document in PouchDB with id 001, which contains id, name, age, designation of an employee along with an attachment as shown below.
An example of deleting the attachment of this document 001 stored in PouchDB, using removeAttachment() method is given below.
With this the attachment of the document is deleted and a message is displayed on the console as shown below.
After deletion, the contents of the document can be verified by executing the following code.
Save this code as read.js and execute it. On executing, the contents of the document after deleting the attachment are given, as shown below.
An attachment of an existing document can be deleted in the database that is stored remotely on the server (CouchDB).
To do so, instead of a database name, you need to pass the path to the database in CouchDB, which contains the document that is to be read.
Suppose there is a database named my_database in the CouchDB server. Then, if the list of databases in CouchDB is verified using the URL http://127.0.0.1:5984/_utils/index.html you will get the following screenshot.
On selecting the database named my_database, its contents can be viewed as shown below.
Suppose there is an attachment in this document as shown below.
An example of deleting the above mentioned attachment of the document 001 that exists in a database named my_database which is stored in the CouchDB server is given below.
With this the existing attachment is removed and the following message is displayed.
On visiting the document again, the deleted attachment can be noticed as shown in the following screenshot.
PouchDB Related Interview Questions
|Java Script Interview Questions||Adv Java Interview Questions|
|Core Java Interview Questions||CorelDRAW Interview Questions|
|Angular JS Interview Questions||MYSQL DBA Interview Questions|
|NoSQL Interview Questions||CouchDB Interview Questions|
|MongoDB Interview Questions||Advanced C++ Interview Questions|
|Basic C Interview Questions||Stored Procedures Interview Questions|
All rights reserved © 2020 Wisdom IT Services India Pvt. Ltd
Wisdomjobs.com is one of the best job search sites in India.