Skip to content

Instantly share code, notes, and snippets.

@goofmint
Created May 11, 2018
Embed
What would you like to do?
let db;
let version = 1;
const request = indexedDB.open("database", version);
request.onerror = function(event) {
alert("IndexedDB が使えません");
};
request.onupgradeneeded = function(event) {
db = event.target.result;
const objectStore = db.createObjectStore("items", { keyPath: "id" });
objectStore.createIndex("name", "name", { unique: false });
objectStore.createIndex("description", "description", { unique: true });
};
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