Please note, this is a STATIC archive of website www.javatpoint.com from 19 Jul 2022, cach3.com does not collect or store any user information, there is no "phishing" involved.
Javatpoint Logo
Javatpoint Logo

PouchDB Read/Retrieve Document

The db.get() method is used to read or retrieve the document created in a database. This method also accepts the document id and optional callback function.

Syntax:


PouchDB Read Document Example

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

It will read the document stored in "Second_Database" on PouchDB Server.

PouchDB Read document 1

Read a Document from Remote Database

You can read or retrieve a document from a remote database (CouchDB). For this, you have to pass the path of the database in CouchDB, which contains the document that you want to read instead of the database name.

Example

There is a database named "employees" in the CouchDB Server.

PouchDB Read document 2

By clicking on "employees", you can see a document:

PouchDB Read document 3

Let's fetch data of that document:

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

It will read the document stored in "employee" database on CouchDB Server.

Output:

{ _id: '001',
  _rev: '3-276c137672ad71f53b681feda67e65b1',
  name: 'Ajeet',
  age: 28,
  designation: 'Developer' }
PouchDB Read document 4




Youtube For Videos Join Our Youtube Channel: Join Now

Feedback


Help Others, Please Share

facebook twitter pinterest

Learn Latest Tutorials


Preparation


Trending Technologies


B.Tech / MCA