Javatpoint Logo
Javatpoint Logo

CouchDB Create View

There are two employees in our "employees" database.

CouchDB Create view 1

Let's suppose employee1 and employee2:

CouchDB Create view 2
CouchDB Create view 3

Now, Open Fauxton and go to all documents where you see a block named New View.

CouchDB Create view 4

Click on new view and fill the required fields:

CouchDB Create view 5

View is created now. You can verify it and get view result by follow the following commands:

Create a file as "app.js", having the following code:

Execute the following code:

CouchDB Create view 6

Open the local browser: localhost:3000

CouchDB Create view 7

List Databases

CouchDB Create view 8

Create a folder "view" and then create a file "index.ejs" within it, having the following code:

Now change in the "app.js" file:

CouchDB Create view 9
CouchDB Create view 10

Get View Result

CouchDB Create view 11

Click on all and then click on API URL to copy the url.

CouchDB Create view 12

Now go to app.js and change the code with the following:

CouchDB Create view 13

Now start server and you will see the following result:

CouchDB Create view 14

To see the documents details

Edit "app.js" with the following code:

Output:

CouchDB Create view 15




Please Share

facebook twitter google plus pinterest

Learn Latest Tutorials


B.Tech / MCA