indexeddb 相关问题

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

将 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

为什么这个 IndexDB 无法识别我的 TotalMoney 对象 Store

我是索引数据库的新手,所以这可能是一个简单的修复,但我似乎无法在我的代码中找到任何修复。我正在使用实时服务器来显示它,我面临的问题是它应该...

回答 1 投票 0

WASM IDBFS 不持久

我有一个加载 wasm 模块的 HTML 页面。 我将这段 JS 代码添加到 html 中: // 在IDBFS中创建一个目录来存储文件 FS.mkdir('/持久'); // 挂载IDBFS作为文件系统 FS.挂载(...

回答 1 投票 0

将 Service Worker 和 IndexedDB 类型添加到 eslint 配置

当我在打字稿文件中使用 ServiceWorkerGlobalScope、FetchEvent、IDBIndexParameters、IDBTransactionMode 等类型,同时为我的应用程序添加 PWA 设置时,ESLint 会抱怨。

回答 1 投票 0

如何更新indexedDB中数组的对象?

例如我有一个对象数组: const arrayOfPersons = [ { 姓名:'亚历克斯',ssn:123,孩子:[ { name: 'Tom', 出生年份: '2023', isHappy: true }, { 名字:'艾玛',yearO...

回答 1 投票 0

降级/回滚IndexedDB?

我面临着一种情况,我可能需要将我的网络应用程序回滚到以前的版本,因为新版本中存在一个错误,需要一些时间才能修复。 我知道 IDB 支持所需的升级...

回答 1 投票 0

使用 Dexie Js 获取索引数据库中保存的记录数

我是 Angular 和 JS 的新手。现在我正在编写代码将数据保存到索引数据库,我想显示“否”。导航栏上待处理的记录(在索引数据库中),我无法获取...

回答 1 投票 0

IndexedDB onsuccess/onfailure 事件监听器:为什么将其分配在打开操作之后而不是之前?

例如 让数据库; // 让我们打开数据库 const DBOpenRequest = window.indexedDB.open("toDoList", 4); // 这些事件处理程序作用于正在打开的数据库。 DBOpenRequest.onrr...

回答 1 投票 0

我们可以在flutter web中使用dart在indexedDb上建立索引吗?

我尝试过为flutter web实现Hive,但发现它不提供添加索引。底层的indexedDb提供了添加索引,但Hive不提供(至少我无法...

回答 1 投票 0

如何使用 JsStore 填充索引数据库中的 DateTime 列

这是我的桌子: { 名称:“测试”, 列 : { K_A:{数据类型:“字符串”}, DT_VAL:{数据类型:“日期时间”}, DT_...

回答 1 投票 0

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