Last active
October 2, 2015 21:08
-
-
Save bergantine/2321617 to your computer and use it in GitHub Desktop.
Temp Share: createDatabase() Function. #demo #javascript #database
This file contains hidden or 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 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