Re: [w3c/IndexedDB] JSON schema specification (#64)

As far as defining stores and indexes via JSON, I've made a [suggestion](https://github.com/json-schema-org/json-schema-spec/issues/17) that JSON Schema itself specify IndexedDB properties so that a store and indexes can be built out of such JSON Schema documents (as well as add constraints above and beyond those within IndexedDB), and also made a [suggestion](https://github.com/json-schema-org/json-schema-spec/issues/19) for allowing JSON Schema (and its IndexedDB features) to be incrementally upgraded by JSON-based means.

(And FWIW, in the case of incremental versioning of JSON without JSON Schema, I'm working on such code for db.js built on top of @alekseykulikov's idb-schema and hope to add as a separate library.)

As far as whether to add support for JSON-based schema upgrades within IndexedDB, there are limitations to what an upgrade can accomplish non-programmatically. For example, it may be possible that you have a string identifier stored in a number of places but with a version upgrade, you want to pad it with 0's up to a certain length. For this, the programmatic approach (as used in`idb-schema` with its `addCallback` method) would be required (and even the `idb-schema` approach is currently limited if you want to use promises within the callback since the `upgradeneeded` transaction is too short-lived as a result of issue #42 (FWIW, I've made some PRs, starting with [# 12](https://github.com/treojs/idb-schema/pull/12) to override `onsuccess` to allow promise-based "upgrade" content modifications to be made, but I hope such workarounds would become unnecessary).

While the `onversionchange` trick mentioned in the OP may work in some cases, it could become problematic if the old code is still seeking to add data to a now-deleted store, etc. I think service workers would be required if you want to recover without a page refresh.

---
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/w3c/IndexedDB/issues/64#issuecomment-212266217

Received on Wednesday, 20 April 2016 05:31:33 UTC