Skip to content

Instantly share code, notes, and snippets.

View ryandabler's full-sized avatar

Ryan Dabler ryandabler

View GitHub Profile
@ryandabler
ryandabler / IndexedDB example.js
Created May 2, 2018 01:50
Working example of an IndexedDB implementation to handle transactions surrounding a fake invoice database
const request = window.indexedDB.open("database", 1);
// Create schema
request.onupgradeneeded = event => {
const db = event.target.result;
const invoiceStore = db.createObjectStore("invoices", { keyPath: "invoiceId" });
invoiceStore.createIndex("VendorIndex", "vendor");
const itemStore = db.createObjectStore("invoice-items", { keyPath: ["invoiceId", "row"] });