Uncaught DOMException: Failed to execute 'transaction' on 'IDBDatabase': One of the specified object stores was not found
Первый раз работаю с indexedDB, не могу понять в чем проблема, помогите пожалуйста. Вот код:
import React from "react";
function App() {
const indexedDB = window.indexedDB;
if (!window.indexedDB) {
alert("Error");
}
const request = indexedDB.open("test-db", 1);
request.onerror = (event) => {
console.log("Error", event);
};
request.onupgradeneeded = function () {
const db = request.result;
const store = db.createObjectStore("NoteItem", { keyPath: "id" });
store.createIndex("note_title", ["title"], { unique: false });
};
request.onsuccess = (event) => {
const db = request.result;
const transaction = db.transaction("NoteItem", "readwrite");
const notesDB = transaction.objectStore("NoteItem");
};
return <div></div>;
}
export default App;