layout: post
title: PouchDB 5.0.0 - Five years of PouchDB author: Nolan Lawson
Fitting with the fact that PouchDB turned five years old this year, we're proud to announce PouchDB 5.0.0. This release contains the usual number of bugfixes and improvements, as well as several deprecations, since it is a major version bump.
The biggest news in terms of features is support for _bulk_get, which is a new CouchDB API that enables vastly faster replication, set to be debuted in CouchDB 2.0. This API is also shipped in the newly-released PouchDB Server 1.0.0, meaning you can test out the faster replication now.
PouchDB.destroy() (#4223)Having a destroy() function on the PouchDB object was always a little awkward, which is why we introduced the db.destroy() alternative. So now that PouchDB.destroy() is out, upgrading your code should look like this:
PouchDB.destroy('mydb');
becomes:
new PouchDB('mydb').destroy();
Keep in mind that the PouchDB object is no longer usable after you destroy() it. So you should call new PouchDB() again if you want to re-use it.
These events ('create', 'update', and 'delete') were intended to make the changes() API easier to work with, but they ended up being too ambitious and confusing, so 5.0.0 removes them.
If you are relying on these events, then you can upgrade like so:
db.changes({live: true}) .on('create', createListener) .on('update', updateListener) .on('delete', deleteListener);
becomes:
db.changes({live: true}) .on('change', function (change) { if (change.deleted) { deleteListener(change); } else if (change.changes.length === 1 && /^1-/.test(change.changes[0].rev)) { createListener(change); } else { updateListener(change); } });
Keep in mind that this “update vs. create” test is not foolproof (what happens if a 2- document is the first version that gets synced? what happens if two conflicting 1- revisions are synced?), but it will match the old behavior.
Most of the time, your UI should be able to handle document “updates” or “creates” equivalently, so change.deleted becomes the only special case. See Efficiently managing UI state with PouchDB for some details about how to do this.
idb-alt plugin (#4222)This was an alternative IndexedDB adapter based on Level.js, which was experimental and probably unused by anyone except the PouchDB developers themselves.
bulkGet() (#3424)openDatabase() (#4018)'use strict' from eval() (#4344)skip_setup to skipSetup (#3535)FileReader usage in a web worker (#4402)Please file issues or tell us what you think. And as always, a big thanks to all of our new and existing contributors!