Skip to content

Instantly share code, notes, and snippets.

@goofmint
Created May 15, 2018 04:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save goofmint/e5dbe4b4d2971fd0dac88a995a197599 to your computer and use it in GitHub Desktop.
Save goofmint/e5dbe4b4d2971fd0dac88a995a197599 to your computer and use it in GitHub Desktop.
let db;
let version = 2;
const request = indexedDB.open("database", version);
request.onerror = function(event) {
alert("IndexedDB が使えません");
};
request.onupgradeneeded = function(event) {
let txn = event.target.transaction;
debugger;
const objectStore = txn.objectStore("items", { keyPath: "id" });
objectStore.name = 'products';
const index = objectStore.index('name');
index.name = 'title';
};
request.onsuccess = function(event) {
db = event.target.result;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment