Created
April 25, 2012 21:50
-
-
Save cfjedimaster/2493787 to your computer and use it in GitHub Desktop.
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
var openRequest = indexedDB.open("notes",2); | |
//handle setup | |
openRequest.onupgradeneeded = function(e) { | |
console.log("running onupgradeneeded"); | |
var thisDb = e.target.result; | |
//Create Note | |
if(!thisDb.objectStoreNames.contains("note")) { | |
console.log("I need to make the note objectstore"); | |
var objectStore = thisDb.createObjectStore("note", { keyPath: "id" }); | |
objectStore.createIndex("title", "title", { unique: false }); | |
} | |
} | |
openRequest.onsuccess = function(e) { | |
db = e.target.result; | |
console.dir(db); | |
db.onerror = function(event) { | |
// Generic error handler for all errors targeted at this database's | |
// requests! | |
alert("Database error: " + event.target.errorCode); | |
}; | |
console.log("We have a handle to our indexeddb"); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment