W3C home > Mailing lists > Public > public-webapps@w3.org > July to September 2009

Simple Web Storage

From: Chris Anderson <jchris@apache.org>
Date: Wed, 1 Jul 2009 11:55:19 +0200
Message-ID: <e282921e0907010255q1c6ff533l1f9ef56a5a1cbed6@mail.gmail.com>
To: public-webapps WG <public-webapps@w3.org>
Hello,

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
WebStore.drop("dbname");

===

Thoughts?

Chris

-- 
Chris Anderson
http://jchrisa.net
http://couch.io
Received on Wednesday, 1 July 2009 12:04:38 GMT

This archive was generated by hypermail 2.3.1 : Tuesday, 26 March 2013 18:49:32 GMT