I\'m curious if there is a library or a project out there to provide a generic interface to IndexedDB or to WebSQL, depending on user\'s browser\'s support. If they\'re usin
I have written YDN-DB for the exact purpose. It is database wrapper for IndexedDB, WebSql and localStorage, build on the top of closure library.
Beautiful API for secure robust high-performance large-scale web app.
Import lastest minified JS script (see download section) to your HTML files. This will create single object in the global scope, call ydn.db.Storage.
var db = new ydn.db.Storage('db name');
db.setItem('x', 'some value')
db.getItem('x').success(function(value) {
console.log('x = ' + value);
}
Calculate average by using query
q = db.query('customer').average('age');
avg = q.fetch()
q = db.query('customer', 'age').bound(18, 25, true).where('sex', '=', 'FEMALE').select('full_name')
young_girl_names = q.fetch()
p1 = db.key('player', 1);
db.transaction(function() {
p1.get().success(function(p1_obj) {
p1_obj.health += 10;
p1.put(p123_obj);
});
}, [p1]);
String value data can be optionally encrypted using SHA-1 cipher.
db = new ydn.db.Store('store name')
db.setSecret(passphase); // generally send from server side upon login
db.setItem(key, value, 3600*1000); // data expire on one hour
db.getItem(key); // data will be decrypted using the provided passphase