Last active
August 29, 2015 14:06
-
-
Save matthew-andrews/fb57531bd842f042b1a3 to your computer and use it in GitHub Desktop.
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
// Let us open our database | |
var request = window.indexedDB.open("toDoList", 4); | |
// these two event handlers act on the database being opened successfully, or not | |
request.onerror = function(event) { | |
note.innerHTML += '<li>Error loading database.</li>'; | |
}; | |
request.onsuccess = function(event) { | |
note.innerHTML += '<li>Database initialised.</li>'; | |
// store the result of opening the database in the db variable. | |
db = request.result; | |
// Open a transaction on the current database and get a reference to the object store | |
//that we want to pull information out of | |
var transaction = db.transaction(["toDoList"]); | |
var objectStore = transaction.objectStore("toDoList"); | |
// Use get() to get a specific object from the object store, the key of which is "Walk dog" | |
var request2 = objectStore.get("Walk dog"); | |
request2.onerror = function(event) { | |
console.log("There is no record stored for " + request.result.taskTitle); | |
}; | |
request2.onsuccess = function(event) { | |
// Do something with the request2.result! | |
console.log("The deadline time for " + request2.result.taskTitle + " is " + | |
request2.result.hours + ":" + request2.result.minutes + "."); | |
}; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment