Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Schema versioning #183

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
- Fix: Ensure return after rejection (in get and count);
- Fix: Better type-checking for bad schema objects;
- Fix: Polyfill `newVersion` for PhantomJS
- API change (breaking)/Feature: Add `clearUnusedIndexes` option (defaults to `true`);
- API change (breaking)/Feature: Destroy and rebuild stores or indexes if present with different options;
- API addition: Support a `schemas` object keyed to version with values
as `schema` objects. (Utilizes own `IdbImport` class, relying on own fork of `idb-schema` at least for now.);
idb-schema callbacks will be passed db.js `Server` as second argument
- API addition: Support a `schemaBuilder` callback which accepts an
    [idb-schema](http://github.com/treojs/idb-schema) object for incremental,
    versioned schema building and whose `addCallback` method will be
    passed an enhanced `upgradeneeded` event object with a `Server` object
    as a second argument for making db.js-style queries
    (e.g., to modify store content), albeit with certain limitations.
    Along with `schemas`, addresses issues #84/#109
- API addition: Support a `clearUnusedStores` property to conditionally avoid deleting old stores.
- API addition: Add `db.del` alias of `db.delete`
- API addition: Add `del()` alias on `Server` for parity with `idb-batch` (likely to use or adapt for multiple change transactions);
- Feature: Change schema (and allow for `schemas`) to differentiate between "mixed", "whole", "idb-schema", and "merge" types with `schemaType` option (defaulting to `mixed` for `schema` and `whole` for `schemas`, maintaining prior behavior in backward-compatible manner);
- Docs: Update `version` and `schema` to take `schemaBuilder` into account
    (and document `schemaBuilder`).
- Docs: Expand on key behavior examples;
- Docs: Indicate that `key` is optional too
- Docs: Add mention of missing `limit` on `modify`
- Refactoring: Use `const` where possible;
- Refactoring: Change variable placement including reordering static variables according to type (built-in alias, IDB, immutables, cache)
- Refactoring: Avoid try-catch for brevity if will throw in sync body of Promise (but denote which lines may throw)
- Refactoring: simplify transaction building
- Refactoring: Add `lang` attribute for Atom linter-jade package;
- Code comment: `preventDefault` not only for Firefox.
- Code comment: Clarify how old connections may be closed
- Testing: Schema building tests
- Testing: Add tests for caching
- Testing: Add test:local and phantom on package.json scripts
- Testing: Fix server-handler test (expect specific error)
- Testing: Fix test-worker to deal with multiple babel-polyfill instances
- Testing: Remove redundant bad-args test
- Testing: Unregister service worker
  • Loading branch information
brettz9 committed May 4, 2016
commit aefe041b56b5503c3e91746bad2af634d0548662
42 changes: 39 additions & 3 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,40 @@
# CHANGES

## Schema version (unreleased)

- API change (breaking): Will delete unused indexes by default; set a new
property `clearUnusedIndexes` if not desired (when using `schema` or
`whole`-type `schema` objects within `schemas`)
- API addition: Support a `clearUnusedStores` option property to
conditionally avoid deleting old stores (when using `schema` or
`whole`-type `schema` objects within `schemas`).
- API addition: Support a `schemas` object. Its keys are the schema versions
and its values are--if `schemaType` is `"mixed"` (the default, unless
`schema` is used, in which case, it will be treated as `"whole"`)--arrays
containing an object whose single key is the schema type for that version
(either `"idb-schema"`, `"merge"`, or `"whole"`) and whose values are
`schema` objects whose structure differs depending on the schema type.
If `schemaType` is not `"mixed"` (`"whole"`, `"idb-schema"`, or `"merge"`),
each `schemas` key will be a schema version and its value a single
"schema object" (or, in the case of `"idb-schema"`, the function that
will be passed the `IdbSchema` instance). Where an object is expected,
one may also use a function which resolves to a valid object.
- API addition: Support `moveFrom` and `copyFrom` for moving/copying a store
wholesale to another new store.
- API addition: Support a `schemaBuilder` callback which accepts an
[idb-schema](http://github.com/treojs/idb-schema) object for incremental,
versioned schema building and whose `addCallback` method will be
passed an enhanced `upgradeneeded` event object that will be passed a
`Server` object as its second argument for making db.js-style queries
(e.g., to modify store content). This option differs from `schemas` used
with `idb-schema` in that it adds the versions as well as stores and
indexes programmatically. Addresses issues #84/#109
- API addition: If there is an upgrade problem, one can use a `retry` method
on the error event object
- Fix: Add Promise rejection for `update()`.
- Documentation: Update `version` to take `schemaBuilder` into account
(and document `schemaBuilder`).

## Unreleased

- Breaking change: Change `db.cmp()` to return a `Promise` to deliver
Expand All @@ -10,23 +45,24 @@
- Deprecated: on `schema.indexes`, in place of the index `key` property,
`keyPath` should be used.
- API fix: Disallow `map` on itself (only one will be used anyways);
- API addition: Add Server aliases, `put` and `delete`.
- API addition: Add Server aliases, `put` and `delete` (or `del`) and `db.del`
as a `db.delete` alias.
- API change: Allow `desc`, `distinct`, `filter`, `keys`, `map`, `modify`
on `limit`;
- API change: Allow `limit` on `distinct`, `desc`, `keys`;
- API change: Allow `{item:...}` without `key` for sake of unambiguity
- API change: Allow `add`/`update` items to be of any value including
`undefined` or `null`
- API change: Allow Mongoifying of `add`/`update`/`remove` keys
- API change: Disallow key in `count()` if null;
- API change: Disallow key in `count()` if `null`;
- Cross-browser support: Auto-wrap user-supplied `Server.error()` and
`Server.addEventListener('error', ...)` handlers with `preventDefault`
so as to avoid hard `ConstraintError` aborts in Firefox.
- Cross-browser support: add `preventDefault` in error listener so that
`onupgradeneeded` errors will not become reported in Firefox (though it
will occur regardless)
- Cross-browser support (minor): wrap `delete` `onblocked` event's
`newVersion` (=null) with `Proxy` but avoid using using `Proxy`
`newVersion` (=`null`) with `Proxy` but avoid using using `Proxy`
if not present for sake of PhantomJS or older browsers (Firefox);
could not wrap `oldVersion`, however.
- Fix: Ensure there is a promise rejection for a bad schema callback,
Expand Down
18 changes: 16 additions & 2 deletions Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ module.exports = function (grunt) {
},

eslint: {
target: ['src/db.js', 'src/test-worker.js']
target: ['src/db.js', 'src/test-worker.js', 'src/idb-import']
},

babel: {
Expand All @@ -86,7 +86,8 @@ module.exports = function (grunt) {
dist: {
files: {
'dist/db.js': 'src/db.js',
'tests/test-worker.js': 'src/test-worker.js'
'tests/test-worker.js': 'src/test-worker.js',
'dist/idb-import.js': 'src/idb-import.js'
}
}
},
Expand All @@ -101,6 +102,11 @@ module.exports = function (grunt) {
standalone: 'db'
}
}
},
dest: {
files: {
'dist/idb-import.js': 'dist/idb-import.js'
}
}
},

Expand All @@ -117,6 +123,14 @@ module.exports = function (grunt) {
'dist/db.min.js': ['dist/db.js']
}
},
idbImport: {
options: {
sourceMapIn: 'dist/idb-import.js.map' // input sourcemap from a previous compilation
},
files: {
'dist/idb-import.min.js': ['dist/idb-import.js']
}
},
testworker: {
options: {
sourceMapIn: 'tests/test-worker.js.map' // input sourcemap from a previous compilation
Expand Down
Loading