PouchDB Interview Questions & Answers

4 avg. rating (80% score) - 1 votes

PouchDB Interview Questions & Answers

Are you expertise in Pouchdb ? Want to pursue your career in Pouchdb job ? Searching for the best interview questions and answers to fulfill your career dream? Then here’s a solution with wisdom jobs. PouchDB is written in javascript and it is an open-source database inspired by Apache CouchDB that is designed to run well within the browser. It will help the user in setting up applications that would be working both offline and online. It is an in-browser database which lets the system applications to save data locally. This eventually allows the users to have control over all the features of an app although they're offline. Have a look at Wosdomjobs Pouchdb job Interview Questions and answers to crack your job interview.

PouchDB Interview Questions

PouchDB Interview Questions
    1. Question 1. What Is Pouchdb?

      Answer :

      PouchDB is an open-source "in-browser" database API written in JavaScript. It is modeled after CouchDB(a NoSQL database that powers npm). It facilitates you to build applications that work offline and online by using this API. PouchDB uses WebSQL and IndexedDB internally to store the data.

    2. Question 2. How Does Pouchdb Work?

      Answer :

      PouchDB stores data locally using WebSQL and IndexedDB in the browser, when the application is offline. When the application back online, the data is synchronized with CouchDB and compatible servers.

      PouchDB facilitates you to communicate both local and remote databases seamlessly without facing any difference.

    3. Question 3. How Can You Delete A Pouchdb Added Attachment?

      Answer :

      The removeAttachment() method is used to delete an attachment from PouchDB document. To use this method, you have to pass the document id, attachment id, and _rev value. This method also accepts an optional callback function.

      Syntax:

      db.removeAttachment ( docId, attachmentId, rev, [callback] );

    4. Question 4. How Can You Retrieve A Pouchdb Added Attachment?

      Answer :

      The getAttachment() method is used to retrieve an attachment from the PouchDB document. This method always returns blob or buffer objects. You have to pass the document id and attachment id to use this method. This method also accepts an optional callback function.

      Syntax: db.getAttachment( docId, attachmentId, [callback] );  

    5. Question 5. How Can You Add An Attachment To A Document In Couchdb?

      Answer :

      The putAttachment() method is used to add an attachment to a document in PouchDB. You have to pass the document id, attachment id, MIME type along with the attachment. This method also accepts an optional callback function.

      Syntax: db.putAttachment( docId, attachmentId, attachment, type, [callback] );  

    6. Question 6. What Is An Attachment In Pouchdb?

      Answer :

      In PouchDB, an attachment is a binary object that can be attached to a document.

    7. Question 7. How Would You Delete A Batch In Pouchdb?

      Answer :

      The bulkDocs() method is used also for deleting an array of documents. To delete a batch, you have to know the _id and _rev values of the documents.

    8. Question 8. How To Update An Already Created Batch In Pouchdb Database?

      Answer :

      The bulkDocs() method is used to update an array of documents in PouchDB. To update a value of batch, you have to know the _id, _rev and the values that you want to update.

    9. Question 9. What Are The Most Important Features Of Pouchdb?

      Answer :

      The most important features of PouchDB are given below:

      Cross Browser: PouchDB is cross-browser. The API provided by PouchDB works the same in every environment, so, a PouchDB application can be run in various browsers.

      Light Weight: PouchDB is a very light-weight API, it is also included easily just using a script tag.

      Easy to Learn: PouchDB is very easy to learn if you have a prior knowledge of any programming language.

      Open Source: PouchDB is an Open Source Application which is available on GitHub.

    10. Question 10. Which Are The Browsers That Support Pouchdb?

      Answer :

      Following are the main browsers that support PouchDB:

      • Firefox 29+ (Including Firefox OS and Firefox for Android)
      • Chrome 30+
      • Safari 5+
      • Internet Explorer 10+
      • Opera 21+
      • Android 4.0+
      • iOS 7.1+
      • Windows Phone 8+

    11. Question 11. What Are The Advantages Of Using Pouchdb?

      Answer :

      Advantages of using PouchDB:

      PouchDB is extremely fast because it resides within the browser and you don't have any need to perform queries over the network. That's why it is fast.

      The data with any of the supported server can be synchronized and by doing so we can run apps both online and offline.

    12. Question 12. How To Install Pouchdb On Your System?

      Answer :

      There are several ways to install PouchDB on your system but by using Node.js and npm is the easiest and efficient way to install PouchDB.

    13. Question 13. How To Create A Database In Pouchdb?

      Answer :

      A database is created very easily in PouchDB by using constructor.

      Syntax:

      new PouchDB(Database_name) 

      You have to install Node.js and a PouchDB package is required using the require() method to create a database.

      Example:

      //Requiring the package 

      var PouchDB = require('PouchDB'); 

      //Creating the database object 

      var db = new PouchDB('my_database'); 

      console.log ("Database created Successfully."); 

    14. Question 14. What Is The Use Of Db.info() Method In Pouchdb?

      Answer :

      The db.info() method is used to get the information about the database. This method also accepts a callback function.

      db.info([callback])  

      See the given example for retrieving data from the database using the info() method. Here the database name is my_database.

      Example:

      //Requiring the package 

      var PouchDB = require('PouchDB'); 

      //Creating the database object 

      var db = new PouchDB('my_database'); 

      //Database information 

      db.info(function(err, info) { 

       if (err) { 

         return console.log(err); 

       } else { 

         console.log(info); 

       } 

      }); 

    15. Question 15. How To Delete A Database Created In Pouchdb?

      Answer :

      The db.destroy() method is used to destroy a database in PouchDB.

    16. Question 16. How To Use Db.destroy() Method With Node.js To Delete A Database?

      Answer :

      Following is the syntax of using the db.destroy() method. It also accepts a callback function.

      Syntax:

      db.destroy()  

      See the following example how to use db.destroy() method.

      Example:

      //Requiring the package 

      var PouchDB = require('PouchDB'); 

      //Creating the database object 

      var db = new PouchDB('database'); 

      //deleting database 

      db.destroy(function (err, response) { 

       if (err) { 

         return console.log(err); 

       } else { 

         console.log ("Database Deleted"); 

       } 

      }); 

    17. Question 17. How To Delete A Remote Database That Is Stored On A Remotely Server Couchdb?

      Answer :

      Provide the path of the remotely database CouchDB in PouchDB constructor to delete a database that is stored on a remotely server CouchDB.

      For example:

      //Requiring the package 

      var CouchDB = require('Couchdb'); 

      //Creating the database object 

      var db = new PouchDB('http://localhost:5984/my_database'); 

      //deleting database 

      db.destroy(function (err, response) { 

       if (err) { 

         return console.log(err); 

       } else { 

         console.log("Database Deleted"); 

       } 

      }); 

    18. Question 18. What Is The Use Of Db.put() Method In Pouchdb?

      Answer :

      The db.put() method is used to create documents in PouchDB databases.

      Syntax:

      db.put(document, callback) 

      This method also supports callback function.

    19. Question 19. How Can You Fetch The Created Document In Pouchdb Database?

      Answer :

      The db.get() method is used to retrieve the documents created in PouchDB database. This method accepts the document id and an optional callback function.

      Syntax: db.get(document, callback) 

    20. Question 20. How Can You Update An Existing Document In Pouchdb Database?

      Answer :

      Every time you create a document, a new field _rev is get generated. It is called revision marker. The _rev's value is a unique random number, which is changed every time we make changes to the document.

      The db.put() method is used along with _rev value to update a document.

    21. Question 21. How Can You Delete A Document In Pouchdb?

      Answer :

      The db.remove() method is used to delete the document created in PouchDB database. In this method, id and _rev are to be passed to delete an existing document as shown in the following code. This method accepts an optional callback function. The complete document can also be passed instead of id and _rev.

      Syntax: db.remove( docId, docRev, [callback] ) 

    22. Question 22. What Is Batch? How To Create A Batch In Pouchdb?

      Answer :

      Batch is an array of documents in PouchDB. When you use this method to create documents, it creates unique ids for all the documents in bulk if you not specifies the _id values.

      All the documents you have created in PouchDB can be stored in an array and can be passed as a parameter in this method. This method also accepts callback functions as a parameter.

      Syntax: db.bulkDocs(docs, [options], [callback]) 

    23. Question 23. How To Fetch The Created Batch In Pouchdb Database?

      Answer :

      The allDocs() method is used to fetch the multiple/bulk documents from the database. This method also accepts an optional callback function.

      Syntax: db.allDocs()  

All rights reserved © 2018 Wisdom IT Services India Pvt. Ltd DMCA.com Protection Status

PouchDB Tutorial