Last active
January 8, 2021 18:09
-
-
Save ashwinkumar2438/0f15a161d4fcb7c71665050f8344ad42 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
let openRequest = indexedDB.open("mystore", 3); | |
openRequest.onupgradeneeded = function(event) { | |
let db = openRequest.result; | |
switch(event.oldVersion) { // existing db version | |
case 1: | |
// do changes for update from version 1 to 3... | |
db.createObjectStore("books",{autoIncrement:true}); | |
case 2: | |
// do changes for update from version 2 to 3... | |
let booksStore=openRequest.transaction.objectStore("books"); | |
books.createIndex("name","book_name",{unique:false}); | |
db.createObjectStore("users",{autoIncrement:true}); | |
} | |
}; | |
openRequest.onerror = function() { | |
console.error("Error", openRequest.error); | |
}; | |
openRequest.onsuccess = function() { | |
let db = openRequest.result; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment