About how IDBDatabase objects in indexedDB have been generated but cannot call the createObjectStore method to create namespaces?

the IDBDatabase object in indexedDB has been generated but cannot call the createObjectStore method to create a namespace, prompting Uncaught TypeError: Cannot read property "createObjectStore" of undefined.
here is the code

    var request = indexedDB.open("jusing"),
        db;
        user = {
            username: "jusing",
            age: 18,
            gender: "male",
            handsome: true
        }
    request.onsuccess = function() {
        db = event.target.result;
    }
    var store = db.createObjectStore("users", {keyPath: "username"});
    store.add(user);
May.29,2021

first of all, db is not assigned at all, and then createObjectStore cannot be used in onsuccess .

to update the schema, of the database, that is, to create or delete the object storage space, you need to implement the onupgradeneeded handler, which will be called as part of a versionchange transaction that allows you to handle the object storage space.

Using_IndexedDB

var request = indexedDB.open("jusing"),
    db;
user = {
    username: "jusing",
    age: 18,
    gender: "male",
    handsome: true
}
request.onupgradeneeded  = function() {
    db = event.target.result;
    var store = db.createObjectStore("users", { keyPath: "username" });
    store.add(user);
}
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b370ed-2c058.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b370ed-2c058.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?