PouchDB Delete DocumentThe db.remove() method is used to delete a document from PouchDB database. You have to pass id and _rev value to delete an existing document. This method accepts an optional callback function. You can also pass the complete document instead of id and _rev. Syntax: Delete Document ExampleFirst retrieve the value of a document which you want to delete by using Read Document method. This document is stored in a database named "Second_Database" in PouchDB. Now, use remove() method with _rev value and id of the document. Save the above code in a file named "Delete_Document.js" within a folder name "PouchDB_Examples". Open the command prompt and execute the JavaScript file using node: Output: VerificationYou can verify that your document is deleted or not by retrieving your document. If it is deleted it will show message: You can see that document is deleted. Delete a Document from Remote DatabaseYou can delete an existing document in a database which is stored remotely on CouchDB Server. For this, you have to pass the path of the database which contains the document that you want to delete. ExampleWe have a database named "employees" on the CouchDB Server. The employee database has a document having id "001". Let's delete the above document. Save the above code in a file named "Delete_Remote_Document.js" within a folder name "PouchDB_Examples". Open the command prompt and execute the JavaScript file using node: Output: VerificationCheck CouchDB server. There is no document in "employee" database. Next TopicPouchDB Create Batch |