Skip to content

Instantly share code, notes, and snippets.

@nolanlawson
Created July 12, 2014 02:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nolanlawson/9931b9a20373a3443991 to your computer and use it in GitHub Desktop.
Save nolanlawson/9931b9a20373a3443991 to your computer and use it in GitHub Desktop.
Post-mortem

Quick post-mortem on this, since I think it's interesting. :)

The idea itself was excellent. By hooking into the Level* ecosystem, we got a number of different backends for free*: in-memory (both client and server), localStorage, RiakDOWN, SqlDOWN, etc.

We never did replace the IndexedDB and WebSQL adapters, though. Part of that was probably a self-fulfilling prophesy on my part, because I went to extreme lengths to get both adapters passing on Safari, IE, Android, iOS, PhantomJS, and now even the Cordova SQLite Plugin on both iOS and back to Android 2.3. Then I performance-tuned the hell out of them.

So now I think we're invested enough in idb.js and websql.js, and the performance is tuned so tightly to those specific APIs, that switching to level.js/WebDOWN/SqlDOWN would be too big a cost to bear in terms of performance (level.js is currently 2x slower). And we'd get little gain in developer efficiency, since our implementations are pretty rock-solid by now. In fact I think PouchDB may be at the forefront of finding browser bugs in WebSQL/IndexedDB implementations, because there are a number of bugs we've discovered that I haven't seen mentioned anywhere else.

That asterisk up above is because integrating with Level* was not completely free; I essentially took on ownership of localstorage-down, @calvinmetcalf took up WebDOWN and SqlDOWN, and along with @adamshish the three of us submitted plenty of bugfixes to abstract-leveldown, node-levelup, MemDOWN, etc.

This is exactly why the idea was so good, though – there were positive externalities where the bugs we fixed spilled over into the level* world. Our test suite was even recently used to find bugs in RiakDOWN. Eventually the PouchDB test suite might just become a de-facto second acceptance test for *DOWN modules (see this).

In any case, now you can sync from CouchDB to a Riak server to IndexedDB in the browser to an in-memory PouchDB Server to WebSQL running in PhantomJS to a PhoneGap app running Android 2.3. That's pretty incredible.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment