BT

Facilitating the Spread of Knowledge and Innovation in Professional Software Development

Write for InfoQ

Topics

Choose your language

InfoQ Homepage News PouchDB – a CouchDB-inspired Offline Web Database

PouchDB – a CouchDB-inspired Offline Web Database

Inspired by Apache CouchDB, PouchDB (Portable CouchDB) is a small footprint database for web and especially mobile applications that need a browser-based storage solution that can be used offline. The database can be synchronized with CouchDB databases or other PouchDBs when the device comes back online.

PouchDB is actually a JavaScript library, 131KB in size in compressed form, that currently can perform the following set of basic tasks: create/query/replicate/delete a database, create/fetch/update/delete document(s), retrieving database information and listening to database changes.

The database also comes with an HTTP RESTful adapter that can be used to synchronize its content with other CouchDB/PouchDB databases.

PouchDB uses the HTML5 IndexedDB API to access the underlying storage engine used by the browser, SQLite in Firefox and LevelDB in Chrome. Work is in progress to support Web SQL, Local Storage and node.js. Unfortunately, Web SQL has been deprecated by W3C, but PouchDB will still support it because “mobile browsers support for IndexedDB is lagging far behind Web SQL”, according to Dale Harvey, the creator of PouchDB.

When we asked what are possible scenarios where PouchDB becomes useful, Harvey said:

Any web application (mobile of otherwise) that is required to work offline (which I believe most of them should). Any application that works offline as well as 'in the cloud' is going to have to deal with the issues of syncing data reliably, and so I think could potentially use PouchDB. The obvious examples are things like To-do lists / data management type apps.

Comparing PouchDB with a CouchDB offline installation, Harvey added:

CouchDB works great on the server, however it is obviously impossible to work with in an offline web application. PouchDB is a tiny embeddable CouchDB that can work in the browser and talk to your much more fully featured CouchDB when it is online.

PouchDB is currently in alpha and has been tested with Firefox +12 and Google 19+. It is likely work with all the browsers that implement the IndexedDB API. The code is available on GitHub under an Apache 2.0 license.

Rate this Article

Adoption
Style

BT