W3C home > Mailing lists > Public > www-tag@w3.org > February 2013

Re: IndexedDB, what were the issues? How do we stop it from happening again?

From: Marcos Caceres <w3c@marcosc.com>
Date: Tue, 12 Feb 2013 17:00:31 +0000
Message-Id: <0791E36D-CB10-42E6-9E6D-AB1749809FE5@marcosc.com>
Cc: "www-tag@w3.org" <www-tag@w3.org>
To: Kyaw Tun <kyawtun@yathit.com>


On 12/02/2013, at 5:02 AM, Kyaw Tun <kyawtun@yathit.com> wrote:

> The criticisms on IndexedDB API by pointing out IndexedDB suck links is unfair. If they have enough time to play around it, they will love it. There are a lot of beauty in IndexedDB API like composite index, element-wise indexing, auto commit transaction, powerful serialisation and full reflection.

Sorry, I didn't make myself very clear. The features of IndexedDB are not in question - they are all awesome, no doubt! It is the *interface* that humans use to interact with those features that appears to suck. 

> Arms with these it is very possible to write butter smooth database library.
> 
> I would like to point out my own open source library as an example: https://bitbucket.org/ytkyaw/ydn-db    

Everything below looks awesome! Why did you feel it was necessary to write a layer on top of IndexedDB? 

> .
> The library features:
> 
> Support all features of asynchronous IndexedDB API.
> Well tested closure library module.
> Fixed schema, auto versioning, on-the-fly schema generation while maintaining multiple connections (on tabs, or worker).
> Low-level cursor iteration, high level query and key joining algorithms.
> Each method call is an atomic transaction, while supporting transaction and advance transaction workflow.
> 
> CRUD operations :
> var db = new ydn.db.Storage('test-store');
> db.put('store1', {test: 'Hello World!'}, 123);
> var req = db.get('store1', 123).done(function(record) {
> 
>   console.log(record);
> 
> });
> 
> 
> 
> Basic query 
> 
> var lower = + new Date(1942, 1, 1); // 1942 February 1
> 
> var upper = + new Date(1942, 2, 1); // 1942 March 1
> 
> var iter = ydn.db.IndexValueCursors.where('author', 'born', '>=', lower, '<', upper);
> 
> db.values(iter).done(function(records) {
> 
>   console.log(records);
> 
>   records.map(function(x) {
> 
>     console.log(x.first + ' ' + x.last + ' ' + new Date(x.born));
> 
>   });
> 
> });
> 
> Advanced query for: SELECT * FROM article WHERE license = 'SA' AND publisher = 'Nature' ORDER BY 'title' 
> 
> 
> var license_sa_iter = ydn.db.Cursors.where('article', 'license, title', '^', ['SA']);
> 
> var publisher_nature_iter = ydn.db.Cursors.where('article', 'publisher, title', '^', ['Nature']);
> 
> var match_keys = [];
> 
> var solver = new ydn.db.algo.ZigzagMerge(match_keys);
> 
> var req = db.scan([license_sa_iter, publisher_nature_iter], solver);
> 
> req.then(function() {
> 
>   db.list('article', match_keys).done(function(results) {
> 
>     console.log(results);
> 
>   });
> }, function(e) {
> 
>   throw e;
> 
> });
Received on Tuesday, 12 February 2013 17:01:17 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Tuesday, 12 February 2013 17:01:18 GMT