PouchDB Delete Database
PouchDB Delete Database
- db.destroy() - Delete a database in PouchDB. This method takes a callback function as a parameter.
Syntax
Delete Database Example
To delete a database named "First_Database" in PouchDB, you can use the destroy() method.
- Save the file "Delete_Database.js" within a folder name "PouchDB_Examples". Open the command prompt and execute the JavaScript file:
PouchDB Delete Database
Delete a Remote Database
You can delete a database that is stored remotely on the CouchDB server. You just have to pass the path of the CouchDB database which you need to delete instead of database name.
- The following example will delete a database that is saved in the CouchDB server. This following code will delete the database named "employees".
Read Also
PouchDB Delete Database
- Save the above code in a file named "Delete_Remote_Database.js" within a folder name "PouchDB_Examples". Open the command prompt and execute the JavaScript file:
PouchDB Delete Database
Output
Now the "employees" database is deleted. You can verify it on CouchDB server. You can see that "employees" database is not available in the database's list.
PouchDB Delete Database