简体   繁体   English

IndexedDB:无法在“IDBDatabase”上执行“事务”:未找到指定的 object 商店之一

[英]IndexedDB: Failed to execute 'transaction' on 'IDBDatabase': One of the specified object stores was not found

I just start a indexedDB for my react PWA.我只是为我的反应 PWA 启动了一个 indexedDB。 And i get this error.我得到这个错误。

Uncaught DOMException: Failed to execute 'transaction' on 'IDBDatabase': One of the specified object stores was not found. at request.onsuccess

line is: const transaction = db.transaction("storeName", "readwrite");行是: const transaction = db.transaction("storeName", "readwrite");

and the func i did:和我做的功能:

  const handleSubmit = (event) => {
    event.preventDefault();

    const request = window.indexedDB.open("NewApp", 1);

    request.onsuccess = () => {
      if (nameArea && enterDate) {
        const db = request.result;
        const transaction = db.transaction(["apps"], "readwrite");
        const store = transaction.objectStore("apps");
        store.put({ nameArea, enterDate: Date.now() });

        const query = store.get(1);

        query.onsuccess = function () {
          console.log("next info", query.result);
        };

        transaction.oncomplete = function () {
          /db.close();
        };
      };

      request.onerror = function (event) {
        console.error("An error occurred with IndexedDB");
        console.error(event);
      };
    }
  };

That problem is in only new opened browser, when i debug it records are adding but not only empty string.这个问题只出现在新打开的浏览器中,当我调试它时,记录正在添加但不仅仅是空字符串。

I just changed the version and recreate db.我只是更改了版本并重新创建了数据库。 So now it's working.所以现在它正在工作。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 IndexedDB 错误:NotFoundError:无法在“IDBDatabase”上执行“事务”:未找到指定的对象存储之一 - IndexedDB Error : NotFoundError : Failed to execute 'transaction' on 'IDBDatabase': One of the specified object stores was not found indexedDB创建数据库并添加内容无法在“ IDBDatabase”上执行“事务” - indexedDB Creating a database and adding content Failed to execute 'transaction' on 'IDBDatabase' 填充许多ObjectStore时出现IndexedDB,错误:无法在“ IDBDatabase”上执行“事务”:版本更改事务正在运行 - IndexedDB when populating many ObjectStores, Error: Failed to execute 'transaction' on 'IDBDatabase': A version change transaction is running 未捕获的 InvalidStateError:无法在“IDBDatabase”上执行“事务”:版本更改事务正在运行 - Uncaught InvalidStateError: Failed to execute 'transaction' on 'IDBDatabase': A version change transaction is running InvalidStateError:无法在“IDBDatabase”上执行“事务”:数据库连接正在关闭 ios safari - InvalidStateError: Failed to execute 'transaction' on 'IDBDatabase': The database connection is closing with ios safari 无法在“IDBDatabase”上执行“createObjectStore” - Failed to execute 'createObjectStore' on 'IDBDatabase' NotFoundError:在indexedDB中创建事务时,DOM IDBDatabase异常8 - NotFoundError: DOM IDBDatabase Exception 8 when creating transaction in indexedDB 如何在交易中创建IndexedDb商店? - How to create IndexedDb stores in a transaction? IndexedDB“操作失败,因为找不到请求的数据库对象。 ” - IndexedDB “The operation failed because the requested database object could not be found. ” 如何在IndexedDB中创建多个对象存储 - How to create multiple object stores in IndexedDB
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM