Home » Pouchdb Delete Database

Pouchdb Delete Database

by Online Tutorials Library

PouchDB Delete Database

The db.destroy() method is used to delete a database in PouchDB. This method accepts a callback function as a parameter.

Syntax:


Delete Database Example

Let’s delete database named “First_Database” in PouchDB using destroy() method.

Save the above code in a file named “Delete_Database.js” within a folder name “PouchDB_Examples”. Open the command prompt and execute the JavaScript file using node:

PouchDB Delete database 1


Delete a Remote Database

You can delete a database that is stored remotely on the server (CouchDB). You just have to pass the path of the CouchDB database which you want to delete instead of database name.


Delete Remote Database Example

The following example will delete a database that is saved in the CouchDB server. This following code will delete the database named “employees”.

PouchDB Delete database 2

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 using node:

Output:

PouchDB Delete database 3


Verification

The database “employees” is deleted now. You can verify it on CouchDB server. You can see that “employees” is not available in the database’s list.

PouchDB Delete database 4

You may also like