Skip to content

Instantly share code, notes, and snippets.

@bergantine
Last active October 2, 2015 21:08
Show Gist options
  • Select an option

  • Save bergantine/2321617 to your computer and use it in GitHub Desktop.

Select an option

Save bergantine/2321617 to your computer and use it in GitHub Desktop.
Temp Share: createDatabase() Function. #demo #javascript #database
function createDatabase() {
try {
var shortName = dataConfig.database;
var version = dataConfig.databaseVersion;
var displayName = dataConfig.database;
var maxSize = dataConfig.databaseMaxSize;
db = openDatabase(shortName, version, displayName, maxSize);
db.transaction(function(transaction) {
transaction.executeSql(
'CREATE TABLE IF NOT EXISTS volumes (volume INTEGER NOT NULL PRIMARY KEY, cover BLOB NOT NULL, contents BLOB NULL, updated DATETIME NOT NULL, date TEXT NOT NULL, hash BLOB NOT NULL, downloadpath TEXT NOT NULL);',
[],
function() {
// callback function here
alert('created table for volumes');
return;
},
errorHandler
);
transaction.executeSql(
'CREATE TABLE IF NOT EXISTS purchases (purchased INTEGER DEFAULT 0);',
[],
function() {
// callback function here
alert('created table for purchases');
return;
},
errorHandler
);
});
} catch(err) {
alert(err);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment