PouchDB is an open source in-browser database API written in JavaScript. It is modelled after CouchDB − a NoSQL database that powers npm. Using this API, we can build applications that work offline and online. PouchDB uses WebSQL and IndexedDB internally to store the data.
This tutorial discusses the basics of PouchDB along with relevant examples for easy understanding.
Audience
This tutorial has been prepared for beginners to help them understand the basic concepts of PouchDB. It will aid you to build applications which will work offline and online alike using PouchDB and CouchDB.
Prerequisites
The reader should have a basic knowledge of databases. It would be better to have a good command on programming languages, which are compatible with node.js such as JavaScript and CoffeeScript.
What is PouchDB?
PouchDB is an open source in-browser database API written in JavaScript. It is modelled after Couch DB &minuss; a NoSQL database. Using this API, we can build applications that work offline and online. It internally uses WebSQL and IndexedDB to store data.
How Does it Work?
In PouchDB, when the application is offline, the data is stored locally using WebSQL and IndexedDB in the browser. When the application is back online, it is synchronized with CouchDB and compatible servers.
Using PouchDB, you can communicate with both local and remote databases seamlessly without noticing any difference.
Features of PouchDB
Following are the features of PouchDB −
- Cross Browser − The API provided by PouchDB works the same in every environment, therefore, we can run a PouchDB application 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 − If you have a prior knowledge of any programming language, it is easy to learn PouchDB.
- Open Source − PouchDB is an Open Source Application and is available on GitHub.
Advantages of PouchDB
Following are the advantages of PouchDB −
- Since PouchDB resides inside the browser, there is no need to perform queries over the network, this results in faster execution of queries.
- You can synchronize the data with any of the supported server and by doing so you can run apps both online and offline.
Browsers that Support PouchDB
Following are the 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+