Skip to content

Instantly share code, notes, and snippets.

@mosquito
Created July 23, 2014 19:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mosquito/0d164ac321abb4208249 to your computer and use it in GitHub Desktop.
Save mosquito/0d164ac321abb4208249 to your computer and use it in GitHub Desktop.
;(function (global) {
var db = function (name, version, comment, size) {
var self = this;
// Arguments parsing
var name = name;
var version = version || '0.1';
var comment = comment || 'Database "' + name + '" created at (' + (new Date()) + ')';
var size = parseInt(size) || 5242880;
self.db = openDatabase(name, version, comment, size);
self.public = {
transaction: function () {
var deferred = Q.defer();
self.db.transaction(function (tx) {
deferred.resolve(tx.executeSql);
});
return deferred.promise;
},
query: function (sql) {
var deferred = Q.defer();
return deferred.promise;
}
};
return self.public;
};
global.DB = db;
})(this);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment