PouchDB Delete BatchThe bulkDocs() method is used to delete an array of documents in PouchDB. You just have to know the _id and _rev values of the documents that you want to delete from the database. You have to add another key-value pair _deleted: true. We have a database named "Second_Database" stored in PouchDB and contains 3 documents: Let's delete the documents using their respective _id and _rev values: Save the above code in a file named "Delete_Batch.js" within a folder name "PouchDB_Examples". Open the command prompt and execute the JavaScript file using node: Output: The batch is now deleted. You can also verify it. VerificationYou can see that there is no document in database. Delete a Batch from Remote DatabaseWe can also delete an array of documents in a database that is stored remotely on a server (CouchDB). You just have to pass the path to the database in CouchDB, which contains the document that you want to delete. ExampleWe have a database named "employees" in the CouchDB Server. There are three documents in "employees" database You can fetch these documents by using node (Read_Remote_Batch.js) command. Now delete all the documents of database "employees". Save the above code in a file named "Delete_Remote_Batch.js" within a folder name "PouchDB_Examples". Open the command prompt and execute the JavaScript file using node: Output: VerificationYou can see that there is no document in "employees"database. Next TopicPouchDB Add Attachment |