PouchDB Read Document
PouchDB Read Document
- db.get() - This method is used to retrieve or read the document created in a database. This method takes the document id and callback function as a parameter.
Syntax
Example:
- Save the file name as "Read_Document.js" within a folder name "PouchDB_Examples". Open the command prompt and execute the JavaScript file:
- It'll examined the document put away in "Second_Database" on PouchDB Server.
Output:
Read Also
PouchDB Read/Retrieve Document
Read a Document from Remote Database
You can also read or retrieve a document from a remotely stored database(CouchDB). You just pass the path of the database where you want to read documents in CouchDB, instead of database name.
Example
- There is a database named "employees" in the CouchDB Server.
PouchDB Read/Retrieve Document
- By clicking on "employees", you can see a document:
PouchDB Read/Retrieve Document
- Let's fetch data of that document:
- Save the file named as "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:
PouchDB Read/Retrieve Document