Last active
August 29, 2015 13:56
-
-
Save rijvirajib/9341768 to your computer and use it in GitHub Desktop.
IndexDBWrapper for IntelXDK with HTML5Shim
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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