使用 jsstore 插入后在浏览器中投影 indexeddb 数据

Projecting indexeddb data in browser after inserting using jsstore

使用 jsstore 插入后在浏览器中投影 indexeddb 数据显示每个 column.Is 中的所有数据是否存在重复数据?为什么它的投影是这样的。

谢谢

indexeddb中的列是object的key,table是object store。在您的情况下,假设键是 - ArticleId 并且列 ArticleId 由 JsStore 索引。

现在让我们看看 idb 中的索引 -

An index is a specialized object store for looking up records in another object store, called the referenced object store. The index is a persistent key-value storage where the value part of its records is the key part of a record in the referenced object store. The records in an index are automatically populated whenever records in the referenced object store are inserted, updated, or deleted. Each record in an index can point to only one record in its referenced object store, but several indexes can reference the same object store. When the object store changes, all indexes that refer to the object store are automatically updated.

所以基本上当您在键上添加索引时,indexeddb 会维护一个特殊的对象存储以搜索记录。

当您在 JsStore 中定义列时 - JsStore 会自动在该列上添加索引,以便我们可以在该列上进行搜索。

所以数据在列和table中没有重复。该列只是引用各自的 primary key ,并且使用 primary key 它可以访问实际存储的值。浏览器仅显示数据之间的关系。

希望这能为您提供有关 indexeddb 列、索引及其存储方式的更多信息。

有关更多信息,请查看 MDN 文章 - https://developer.mozilla.org/en-US/docs/Web/API/IndexedDB_API/Basic_Concepts_Behind_IndexedDB