Object Stores in IndexedDB are like tables in a relational database, containing records of data. Each record includes a key for identification and a value, which can be of any data type.
Code Example :
let openRequest = indexedDB.open("myDatabase", 1);
openRequest.onupgradeneeded = function(e) {
let db = e.target.result;
// Create an object store named "books", with a key path of "isbn"
let store = db.createObjectStore("books", {keyPath: "isbn"});
// Create an index on the "author" property of the objects in the store
store.createIndex("author", "author", {unique: false});
};
openRequest.onsuccess = function(e) {
console.log("Success! Got a handle on the database.");
};
openRequest.onerror = function(e) {
console.error("Unable to open database: ", e.target.errorCode);
};?