-
Notifications
You must be signed in to change notification settings - Fork 0
Version 0.4.0 #32
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
Merged
Merged
Version 0.4.0 #32
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Besides the defined fields, extra fields can be added and queried
It is done anyways for UMD, and for module it is recommended to use import instead
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Features
Disable indexing
Fields allow now to disable the automatic index creation (eg. for non indexable types like Blob)
Migrations
Sometimes, changes to the way existing data is stored are required for an update, to cope with this W-ORM provides an intuitive migration system.
Migrations are defined as list of functions to be executed, depending on the current and target DB versions.
The key is the target version number, and the value is the migration callback.
Eg.
{ 2: (migration) => { ... } }will execute the migration callback when the current database version is smaller than 2.A migration callback receives a
MigrationContextobject as its only argument.This object contains a transaction to be used for the migration.
It is expected for the callback to create Model classes that represent the table's state in between these two versions.
The fields aren't actually used by W-ORM in this scenario, and only serve to improve the typing within the migration.
The
Modelmethods can be then used to manipulate the data.It is very important to use the transaction provided by the migration context, otherwise the migration will hang forever.
Model now allows extra fields
The Typescript signature of
Modelhas been changed so that you can provide and get extra, not defined fields from it. This is a feature supported by IndexedDB so it's only natural to support it here as well.Query cloning
Queries can now be cloned, to allow branching and allow code deduplication.
Model.keys
We can now get a list with all the keys in a table (same as
Model.allbut with keys instead of instances)Bug fixes
initcallOther
distwould break because theModelclass wasn't calledModelanymoredistexposes the whole module underglobalThis.WORM, for the ESM version, you'll have toimport WORM from "https://unpkg.com/browse/@d34d/w-orm@0.4.0/dist/index.esm.js"