Skip to content

Instantly share code, notes, and snippets.

@luke-denton-aligent
Last active November 16, 2016 04:01
Show Gist options
  • Save luke-denton-aligent/55be283cbddf6f0c0d362fd95fc9280a to your computer and use it in GitHub Desktop.
Save luke-denton-aligent/55be283cbddf6f0c0d362fd95fc9280a to your computer and use it in GitHub Desktop.
This snippet shows how to use IndexedDB
// 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