PouchDB - Create Database


You can create a database in PouchDB using the PouchDB constructor.


Following is the syntax of using the PouchDB constructor. To this, you need to pass the name of the database as a parameter.

new PouchDB(Database_name)


To create a database in PouchDB using node, first of all, you need to require the PouchDB package using the require() method and then you can create a database as shown in the following example.

//Requiring the package
var PouchDB = require('PouchDB');

//Creating the database object
var db = new PouchDB('my_database');
console.log ("Database created Successfully.");

Save the above code in a file with the name Create_Database.js. Open the command prompt and execute the JavaScript file using node as shown below.

C:\PouchDB_Examples>node Create_Database.js

This will create a database locally (you can see the folder in the current directory) displaying the following message.

Database created Successfully.