PouchDB 2.0.0

Datetime:2016-08-23 00:48:14         Topic: Leveldb          Share        Original >>
Here to See The Original Article!!!

PouchDB 2.0.0 is out and has a lot of great stuff, first off you’ll notice breaking changes they are:

  • allDbs has died in a fire. This optional disabled by default feature complicated the db creation process to no end and was the source of many race conditions in testing. If you were one of the 3 people using it fear not, while it was previously impossible to get this behavior otherwise it now is due to another new feature.
  • PouchDB now uses prototype for inheritance, no more of that copying methods from object to object. This does mean that var get = db.get will blow up, so write var get = db.get.bind(db) instead.
  • plugin now take advantage of prototype, meaning you can add them after you create a database.
  • For indexedDB and webSQL adapters the schema has been updated to give correct doc counts, your db should migrate fine,
  • for the leveldb adapter we switched from being a folder with 4 leveldb and an annoying ‘.uuid’ file it is a single leveldb with 4 sublevels and no ‘.uuid’ file. This also will transfer your data over the first time you open an old style one in the new.
  • these last 2 mean that v1 PouchDBs will open in v2 but not the other way around. Also v1 ones will become v2 ones as soon as they are opened in the new release so don’t switch back and forth.

Non breaking changes:

  • leveldb based PouchDB creation is now totally async with no fs.
  • all the methods return promises (except the replication ones). This is in addition to taking callbacks. If you hate promises then the only change you’ll notice is that we more consistently return errors instead of throwing. We use the superfast bluebird in node and in the browser we default to native promises and fallback to the supersmall lie.
  • it works in web worker now, including in chrome where you have access to indexedDB inside a worker.
  • we prevent overly enthusiastic caches in IE from preventing requests from reaching CouchDB
  • we no longer screw around with your options object so you can re use it for multiple calls.
  • if you pass emit as the second argument to your temp query function, map reduce no longer evals it.
  • a whole host of things to make replication much faster
  • a whole lot of tweaks to the webSQL adapter thanks to Nolan.
  • the PouchDB constructor is now an event emitter and you can listen for create and destroy events.
  • If somebody has shat all over your JavaScript environment by adding enumerable properties to Object.prototype, PouchDB has you covered.

Some fixes that make developing much easier include

  • qUnit has been totally replaced with mocha and chai, if you’ve ever had the misfortune of using qUnit in node or with async tests or both you’ll know why this is so awesome.
  • all the tmp test dbs are in their own folder which is deleted afterwards, no more mess after failed tests.

Grab it from npm, component or bower, or download the regular or minified version.


Put your ads here, just $200 per month.