As a web and mobile application developer, you may come to a point where you need to worry about data and how to synchronize it between devices in platforms. PouchDB is one of a few good solutions that makes this task significantly easier. In this episode of The Polyglot Developer Podcast, guest speaker Nolan Lawson and I discuss PouchDB and how it is being used in a lot of modern applications, both web and mobile.
Nolan Lawson is a Program Manager at Microsoft, but also one of the core contributors to the PouchDB open source project. In Episode #6: PouchDB and its Usefulness in Browser Based Development, we’re going to cover a lot of ground without actually showing how to use the database in your application. After all, this is an audio only podcast. You will however, be educated on a lot of the technical concepts and popular use cases behind the tool.
This podcast episode can be found for free on iTunes and Pocket Casts, but in case you’d prefer to listen to it from your browser instead, it can be heard below.
For those of you that would rather read than listen, I’m going to explain some of the podcast episode here.
PouchDB is a wrapper library for all the popular web based storage technologies such as, but not limited to, WebSQL, IndexDB, and local storage. It will essentially choose what storage technology is best for the platform that you’re using to maximize compatibility.
PouchDB allows you to not only store data locally, but also synchronize it to a remote data source when able to. Supported remote data sources include CouchDB, Couchbase, PouchDB Server and IBM Cloudant.
By default PouchDB uses a form of long-polling to perform synchronization between remote database and local device, but this can be changed to use sockets instead. However, Nolan recommends the default method for most scenarios.
Per Nolan, PouchDB is used with browser based applications, and Node.js, but most frequently is used with hybrid mobile applications built with Apache Cordova. These include PhoneGap and Ionic Framework. Nolan said that although not directly supported by the PouchDB team, there are also extensions that will make it compatible with frameworks like React Native and NativeScript.
I brought up the topic of TypeScript and type definitions. There are type definitions on DefinitelyTyped that are a bit out of date, but work will be done in the future to make them a core part of the library. This is because frameworks like Angular and Ionic 2 put a much stronger emphasis on TypeScript than frameworks previously did.
When I asked Nolan about any difficulties developers faced when using PouchDB, he right away said the use of JavaScript promises. They are a tricky subject to grasp, but recommends everyone reads an article he wrote called We Have a Problem with Promises.
JavaScript promises were actually a pretty big pain point for me when I was learning Angular. Once you understand how to use them correctly, it gets a lot easier.
Nolan brought up a cool story on the podcast regarding how people in West Africa were using a mobile application that included PouchDB to track the Ebola epidemic. Since internet connections are sparse in West Africa, the data was collected and synchronized remotely as internet became available.
Below is a video presentation from a conference where the Ebola application was discussed.
Trust me when I say this, but the material in the podcast is much better than the summary I included in these show notes. Our discussion is technical on everything PouchDB. If you ever wanted to know how it works or why you should use it in your mobile or web application, listen to the episode.
As of about a week ago, PouchDB 5.4.0 was released which contains the ability to craft custom builds. This is great for developers trying to reduce the overall application size.
If you have questions regarding this podcast episode, you can fill out the form here and either Nolan or myself will get back to you. If you’re listening to this podcast via a service or application and it allows you to leave a rating or review, please give it a positive rating.
If you’d like to check out some PouchDB tutorials that I wrote, check out PouchDB with AngularJS and PouchDB with Ionic Framework. You’ll get a good idea how to use it in your project.