Last active
November 16, 2016 04:01
-
-
Save luke-denton-aligent/55be283cbddf6f0c0d362fd95fc9280a to your computer and use it in GitHub Desktop.
This snippet shows how to use IndexedDB
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
// Offline Web Applications course on Udacity https://classroom.udacity.com/courses/ud899 | |
//idb is a plugin that's available to make it easier to work with IndexedDB | |
//This should all go in a new file, called index.js, in a sub-directory called index-db, or something of the like | |
//Open a new database, giving it a name, version number and a callback function | |
var dbPromise = idb.open('test-db', 1, function(upgradeDb) { | |
var keyValStore = upgradeDb.createObjectStore('keyval'); | |
keyValStore.put('world', 'hello'); //Put the value 'world' into key 'hello' (key/value is seeminlgy back-to-front) | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment