Simple Web Storage


Long time fan, first time writer. ;)

I've been following the Web Storage proposals with interest, and was
just independently drafting a mail suggesting the a B-Tree API would
be much simpler to standardize, and would be an adequate foundation
for building most anything more specific.

I'd like to express my support for a BDB style API. Firstly because it
would be much less prone to vendor differences, and secondly because I
can see how to implement a performant CouchDB on top of it. It could
be a bit harder to build a SQL-like interface on raw B-Trees, but
completely possible if someone is determined.

I don't think we need to worry about specific vendor implementations,
just a unified API with very small surface area. To build CouchDB all
we'd need is B-Trees that support in-order and reverse-order
traversal, and optionally user-defined collation functions.

Here's a first cut at imagining the API:

=== JS pseudocode ===

var btree = new WebStore("dbname", <optional collation function definition>);

btree["mydocid"] = {"some":"json"};

btree.forEach(function(key, value) {
 // in order traversal

btree.forEach(function(key, value) {
 // reverse order traversal
}, false)

btree.forEach("startkey", function(key, value) {
 // in order traversal, starting from "startkey"
 // we could use throw() to stop traversal

btree.forEach("endkey", function(key, value) {
 // reverse order traversal, starting from "endkey"
 // use throw() to stop traversal
}, false)

// delete a btree




Chris Anderson

Received on Wednesday, 1 July 2009 12:04:38 UTC