Skip to content

Instantly share code, notes, and snippets.

@rijvirajib
Last active August 29, 2015 13:56
Show Gist options
  • Save rijvirajib/9341768 to your computer and use it in GitHub Desktop.
Save rijvirajib/9341768 to your computer and use it in GitHub Desktop.
IndexDBWrapper for IntelXDK with HTML5Shim
function IndexDBWrapper() {
this.status = false;
window.db.open({
server: 'cyphrd-sqrl',
version: 1,
schema: {
entry: {
key: {
keyPath: 'id' ,
autoIncrement: true },
// Optionally add indexes
indexes: {
id: {},
domain: {}
}
}
}
}).done( function ( s ) {
this.server = s;
this.status = true;
}.bind(this));
}
IndexDBWrapper.prototype.add = function(entry, callback) {
this.server.entry.add(entry).done(callback);
}
IndexDBWrapper.prototype.update = function (id, entry, callback) {
entry.id = id;
this.server.entry.update(entry).done(callback);
}
IndexDBWrapper.prototype.get = function(id, callback) {
return this.server.entry.get(id).done(callback);
}
IndexDBWrapper.prototype.del = function(id, callback) {
return this.server.entry.remove(id).done(callback);
}
IndexDBWrapper.prototype.queryAll = function(callback) {
return this.server.entry.query('domain').all().execute().done(callback);
}
IndexDBWrapper.prototype.clear = function() {
return this.server.entry.clear();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment