Created
December 2, 2017 03:01
-
-
Save arackaf/93533d357e2f35238f7023e960ebd2a3 to your computer and use it in GitHub Desktop.
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
self.addEventListener("activate", () => { | |
let open = indexedDB.open("books", 1); | |
open.onupgradeneeded = evt => { | |
let db = open.result; | |
if (!db.objectStoreNames.contains("books") || !db.objectStoreNames.contains("syncInfo")) { | |
if (!db.objectStoreNames.contains("books")) { | |
let bookStore = db.createObjectStore("books", { keyPath: "_id" }); | |
bookStore.createIndex("imgSync", "imgSync", { unique: false }); | |
} | |
if (!db.objectStoreNames.contains("syncInfo")) { | |
db.createObjectStore("syncInfo", { keyPath: "id" }); | |
evt.target.transaction | |
.objectStore("syncInfo") | |
.add({ id: 1, lastImgSync: null, lastImgSyncStarted: null, lastLoadStarted: +new Date(), lastLoad: null }); | |
} | |
evt.target.transaction.oncomplete = fullSync; | |
} | |
}; | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment