indexeddb 相关问题

indexedDB提供了一种使用Javascript在浏览器中存储数据的方法。与关系数据库不同,indexedDB使用的键值存储在概念上类似于HTML5的本地存储。但是,indexedDB比本地存储更好,可以存储大量数据并更快地查询数据。虽然对特定功能的支持各不相同,但IE,Chrome,Firefox和Microsoft Edge都支持indexedDB。

声明 js 变量/对象时出错(未捕获 DOMException)

我的脚本遇到错误: 未捕获的 DOMException:尝试使用不可用或不再可用的对象 该脚本应检查数据库是否已满。如果没有填写

回答 1 投票 0

什么可能导致indexeddb事务在我的代码中不起作用

var 数据库 = window.indexedDB.open("myTestDatabase", 3); 数据库.onerror = 函数(事件) { alert('创建数据库时出错'); } database.onupgradeneeded = 函数(事件) { ...

回答 2 投票 0

如何保持indexeddb事务处于活动状态?

只要您使用适当的方法,就可以从单个事务中完成所有这些操作,而不是打开多个事务(读取表、写入表、写入另一个表等)

回答 5 投票 0

修复索引数据库

有没有办法保证indexedDB中对象存储的存在而不改变版本号? 语境: 我的一位用户将 indexedDB 设置为与其他人相同的版本,但是

回答 1 投票 0

禁用 Forge 查看器的 IndexedDB

初始化查看器时是否可以禁用 IndexedDB。我看到一个选项建议将其作为查询参数传递,但是否可以通过查看器初始化函数来完成此操作...

回答 1 投票 0

当文件更改和页面重新加载时,从存储在indexedDB中的文件句柄加载的文件不会更新

使用此处介绍的方法: https://stackoverflow.com/a/65938910/3825996 我创建了一个网页,您可以将文件拖放到任何地方,然后就会显示内容。掉落后,手柄...

回答 1 投票 0

使用 mysql LIKE 在多列上进行 Indexeddb 搜索

我正在开发一个 PWA,我有一个数据库,我想像这样查询: SELECT * FROM 植物 WHERE (plant_genus LIKE 'Ab%') AND (plant_species LIKE 'pr%') 索引定义如下: 调查Pl...

回答 1 投票 0

指定一个字段,按方向查询多字段索引

我的问题与这个问题类似,只是我想在具有多个字段的索引上执行此操作,其中一个字段具有特定值。 例如,我有一家名为ExerciseSe 的商店...

回答 1 投票 0

IndexedDB 中的 Blazor 图像:运行时错误:内存访问越界

我在 Blazor Web 程序集中使用 Steve Sanderson 的 InputFile 来选择照片,在上传之前将其保存为 IndexedDB 中的字节数组。对于非常小的文件来说一切都很好,但是一旦我有两个

回答 1 投票 0

将 SQLite 与 Blazor WASM 结合使用有什么好处?

我正在观看 Steve Sanderson 的这段视频,该视频演示了如何将 SQLite 与 Blazor Web Assembly 结合使用,我正在考虑在我的一个项目中使用它。我只是想了解

回答 2 投票 0

我什么时候应该使用 Web SQL 还是 IndexedDB? [已关闭]

最近,我接触到了浏览器提供的Web SQL和IndexedDB API。 Web SQL 和 IndexedDB 的用例是什么?我什么时候应该使用其中之一?

回答 2 投票 0

使用 Web SQL 与 IndexedDB 相比有何优势? [已关闭]

indexeddb 比浏览器提供的 websql api 好在哪里?

回答 2 投票 0

无法在 Safari 上的 IndexedDB 中存储 Blob 类型

我在 Safari 版本 10.1.2 上的 IndexedDB 中存储 blob 时遇到问题(在 IOS 上也面临同样的问题)。 我正在使用 angular2-indexeddb 模块包装器,但是 - 我不认为这是一个问题......

回答 4 投票 0

捕获(承诺中)DOMException:无法在“IDBCursor”上执行“继续”:光标正在迭代或已迭代超过其末尾

当我使用谷歌浏览器在indexeddb中进行页面查询时,如下所示: 导出异步函数 getPage(page: number, pageSize: number): Promise { 让交易 = (awa...

回答 2 投票 0

IndexedDB 的包装函数

我需要为 iPad/平板电脑设备构建一个离线 HTML5 Web 应用程序,用户可以从服务器下载数据集(数据表)并将其存储在设备上。然后用户可以断开连接...

回答 5 投票 0

mysql和IndexedDB之间的同步

我喜欢使用 nw.js (node-webkit) 或 Electron 开发桌面应用程序。 我正在寻找一种通过 Restful API 在云上的 IndexedDB 和 MySQL Server + PHP(Laravel) 之间同步的解决方案。 PouchDB...

回答 1 投票 0

打开indexedDB.open的后备存储时出现内部错误

我在公共环境中收到此错误日志,在大约 0.1% 的会话中非常一致。 我正在使用德克西。 https://dexie.org/ DexieDB 类扩展了 Dexie { 缓存数据!:表<

回答 3 投票 0

找不到指定的对象存储之一

HTML: HTML: <!DOCTYPE html> <html lang="en"> <head> <link rel="stylesheet" href="../css/create-card.css"> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Card - Create Card</title> </head> <body> <div class="main-div-container"> <div class="input-div-container"> <div class="front-label-div-container"> <label>Front Page</label> </div> <div class="front-page-input-div-container"> <input type="text" class="front-page-input" id="front-page-input"> </div> </div> <div class="input-div-container"> <div class="back-label-div-container"> <label>Back Page</label> </div> <div class="back-page-input-div-container"> <input type="text" class="front-page-input" id="back-page-input"> </div> </div> <div class="button-div-container"> <button class="button" id="button">Save</button> </div> <div class="other-cards"> <a href="/cards"> <button class="other-cards-button">Other Cards</button> </a> </div> </div> <script src="../js/create-card.js"></script> </body> </html> JavaScript: const frontArea = document.getElementById("front-page-input"); const backArea = document.getElementById("back-page-input"); const saveButton = document.getElementById("button"); localStorage.setItem("cardAmount", 0) const indexedDB = window.indexedDB || window.mozIndexedDB || window.webkitIndexedDB || window.msIndexedDB || window.shimIndexedDB; const request = indexedDB.open("Cards-Database", 1) request.onerror = () => { alert("Problem happened in the database"); }; request.onupgradeneeded = () => { const database = request.result; const DbObjectStore = database.createObjectStore("card-values", { keyPath: id }) DbObjectStore.createIndex("front-value", ["front"], { unique: false }) DbObjectStore.createIndex("back-value", ["back"], { unique: false }) }; request.onsuccess = () => { const database = request.result; const transaction = database.transaction("card-values", "readwrite"); const cardStore = transaction.objectStore("card-values"); saveButton.addEventListener("click", () => { const frontValue = frontArea.value; const backValue = backArea.value; const cardAmount = localStorage.getItem("cardAmount") + 1; localStorage.removeItem("cardAmount"); localStorage.setItem("cardAmount", cardAmount); cardStore.add({ id: cardAmount, front: frontValue, back: backValue}); }); alert("Card Created"); } 目的是保存提醒卡以供学习。我得到: 错误:未捕获的 DOMException:无法在“IDBDatabase”上执行“事务”:找不到指定的对象存储之一。 数据库: 您的代码中有一些错误。这是解决方案; 错误1 const cardAmount = localStorage.getItem("cardAmount") + 1; 这里,从localstorage获取cardAmount变量时,必须将该变量转换为int值。否则,会有这样的输出:“01”,“012”... 错误2 const DbObjectStore = database.createObjectStore("card-values", { keyPath: id }) 这里,必须将id参数作为字符串给出,即应该在“id”中。 错误3 要获取输入值并将其保存到数据库,您可以在数据库访问成功后立即启动一个事务,但要等到用户按下按钮才能执行该事务。 IndexedDb 不支持此类操作。这就是为什么您应该在按下按钮的同时开始交易。这样问题就解决了。 纠正全部3个错误后的结果代码; const frontArea = document.getElementById("front-page-input"); const backArea = document.getElementById("back-page-input"); const saveButton = document.getElementById("button"); localStorage.setItem("cardAmount", 0) const indexedDB = window.indexedDB || window.mozIndexedDB || window.webkitIndexedDB || window.msIndexedDB || window.shimIndexedDB; const request = indexedDB.open("Cards-Database", 1) request.onerror = () => { alert("Problem happened in the database"); }; request.onupgradeneeded = () => { const database = request.result; const DbObjectStore = database.createObjectStore("card-values", { keyPath: "id" }) DbObjectStore.createIndex("front-value", ["front"], { unique: false }) DbObjectStore.createIndex("back-value", ["back"], { unique: false }) }; request.onsuccess = () => { const database = request.result; saveButton.addEventListener("click", () => { const frontValue = frontArea.value; const backValue = backArea.value; // Fix for localStorage: Convert cardAmount to int const cardAmount = Number(localStorage.getItem("cardAmount")) + 1; localStorage.removeItem("cardAmount"); localStorage.setItem("cardAmount", cardAmount); // Move the transaction and objectStore creation here const transaction = database.transaction("card-values", "readwrite"); const cardStore = transaction.objectStore("card-values"); cardStore.add({ id: cardAmount, front: frontValue, back: backValue }); transaction.oncomplete = function(event) { alert("Card Add Successfully"); }; transaction.onerror = function(event) { alert("error when try add card"); }; }); alert("Card Created"); }

回答 1 投票 0

Chrome 扩展开发:chrome.storage.local 与 Indexeddb

我目前正在开发一个数字钱包应用程序作为 chrome 扩展,并试图找出应该使用什么作为我的持久存储层:chrome.storage.local 或 indexedDb。我有厕所...

回答 2 投票 0

Chrome 扩展的 LocalStorage 与 IndexedDB?

我有一个 Chrome 扩展程序,我将所有用户数据和设置保存到 LocalStorage。据我所知,它工作得很好,即使用户清除历史记录和 cookie,LocalStorage 也会...

回答 1 投票 0

© www.soinside.com 2019 - 2024. All rights reserved.