问题描述
我想使用Google Chrome的IndexedDB在客户端持久保存数据。
想法是稍后通过Node.JS访问chrome外部的IndexedDB。
背景是在本地跟踪使用行为并将收集到的数据存储在客户端上供以后分析而不需要服务器后端的想法。
据我了解,indexedDB是作为LevelDB实现的。但是,我无法使用任何工具/库打开levelDB,如 / 或。
我总是收到以下错误消息:
leveldb -dump-to-json --file test.json --db https_www.reddit.com_0.indexeddb.leveldb
events.js:141
throw er; //未处理'错误'事件
^ OpenError:无效参数:idb_cmp1与现有比较器不匹配:leveldb.BytewiseComparator $ b $位于/ usr / local / lib / node_modules / leveldb- json / node_modules / levelup / lib /levelup.js:114:34 Christians-Air:IndexedDB
任何人都可以请帮忙吗?看起来好像Chrome的实现在某种程度上是特殊/不同的。
leveldb中的键是任意的二进制序列。客户使用来定义键之间的顺序。 leveldb的相当于 要检查chrome之外的Chrome索引DB leveldb实例,需要实现兼容的比较器。该代码位于Chrome的内容/浏览器/ indexed_db / indexed_db_backing_store.cc的实现中 - 请注意,不能保证这在各个版本中都是固定的。 (当然,除了向后兼容性) I want to use Google Chrome's IndexedDB to persist data on the client-side. Idea is to access the IndexedDB outside of chrome, via Node.JS, later on. The background is the idea to track usage behaviour locally and store the collected data on the client for later analysis without a server backend. From my understanding, the indexedDB is implemented as a LevelDB. However, I cannot open the levelDB with any of the tools/libs like LevelUp/LevelDown or leveldb-json. I'm always getting this error message: Can anybody please help? It seems as if the Chrome implementation is somehow special/different. Keys in leveldb are arbitrary binary sequences. Clients implement comparators to define ordering between keys. The default comparator for leveldb is something equivalent to To inspect one of Chrome's Indexed DB leveldb instances outside of chrome you'd need to implement a compatible comparator. The code lives in Chrome's implementation at content/browser/indexed_db/indexed_db_backing_store.cc - and note that there's no guarantee that this is fixed across versions. (Apart from backwards compatibility, of course) 这篇关于如何访问Google Chrome的IndexedDB / LevelDB文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! strncmp
。 Chrome针对索引数据库存储的比较器更加复杂。如果尝试使用带有不同比较器的leveldb实例,那么它将以看似随机的顺序观察密钥,插入将不可预知或导致讹误 - 狗和猫共同生活,群众歇斯底里。所以leveldb可以让你命名比较器(保存到数据库)来帮助检测和避免这种错误,这就是你所看到的。 idb_cmp1。
leveldb-dump-to-json --file test.json --db https_www.reddit.com_0.indexeddb.leveldb
events.js:141
throw er; // Unhandled 'error' event
^ OpenError: Invalid argument: idb_cmp1 does not match existing comparator : leveldb.BytewiseComparator
at /usr/local/lib/node_modules/leveldb- json/node_modules/levelup/lib/levelup.js:114:34 Christians-Air:IndexedDB
strncmp
. Chrome's comparator for Indexed DB's store is more complicated. If you try and use a leveldb instance with a different comparator than it was created with you'll observe keys in seemingly random order, insertion would be unpredictable or cause corruption - dogs and cats living together, mass hysteria. So leveldb lets you name the comparator (persisted to the database) to help detect and avoid this mistake, which is what you're seeing. Chrome's code names its comparator for Indexed DB "idb_cmp1".