Upgrading to JSData 2.0
Migration path
When upgrading to JSData 2.0 be aware of the following:
JSData no longer ships with a Promise
implementation, even though JSData stills uses Promises. It is up to you to polyfill the environment if a global Promise
constructor isn't available. Here is a handy library for polyfilling: https://github.com/jakearchibald/es6-promise. If you can't polyfill the environment, then you can directly configure JSData to use a specific Promise
library via JSData.DSUtils.Promise = MyPromiseLib;
.
Relation links are no longer computed during DS#inject
, and the various linking methods have been removed. Instead, non-enumerable property accessors are defined on the prototypes of instance constructor functions. Relations links will now always be up-to-date with what's in the data store. See Relations.
JSData no longer has any integration with js-data-schema, so if you have schema: {...}
in your resource definition, it no longer means anything. If you want to continue to use js-data-schema, you'll need to create your own instance of Schemator
, define your schemata manually, and then define your own validate
model lifecycle hooks. It's what you have to do anyway if you're using any other library for validation.
The beforeInject
, afterInject
, beforeEject
, and afterEject
lifecycle hooks are now always called.
By default, computed properties are no longer sent to adapters. This mostly affects DS#create
and DS#save
.
The getEndpoint
method on Resources no longer exists, but has been moved into js-data-http, since HTTP is the concern of the HTTP adapter.
Breaking API changes
- #54 - feat: Call the inject and eject lifecycle hooks regardless of if the notify option is enabled
- #107 - Switch to property accessors (getter/setter) for relations links. (Relation links are no longer enumerable)
- #121 - Remove bundled Promise code (The developer must now ensure an ES6-style Promise constructor is available)
- #122 - Remove coupling with js-data-schema (You can still use js-data-schema, js-data just doesn't know anything about js-data-schema anymore)
- #150 - Debug output,
debug
now defaults tofalse
- #158 - Data store should consume resource definition methods internally (might not be breaking)
- #161 - By default, computed properties are no longer sent to adapters. You can also configure other properties that shouldn't be sent.
- Moved the
getEndpoint
method to the http adapter
Backwards compatible API changes
- Computed properties now support nested fields (both the computed field and the fields it depends on) e.g.
computed: { 'name.fullName': ['name.first', 'name.last', function (first, last) { return first + ' ' + last; } }
- #129 - Add interceptors to actions
- #131 - array of IDs based hasMany relations
- #132 - Allow resources to extend other resources
- #133 - Allow filtering by nested fields
- #135 - JSData caching inconsistent behaviour when ejecting items
- #138 - Collection class
- #139 - Option to specify default values of new resource instances.
- #145 - A little AOP, add a
.before
to all methods, allowing per-method argument customization - #157 - DSEject not available on instances
- #160 - Add "DS.change" events, fired on Resources and instances
- #162 - Return query metadata as second parameter from a promise.
- #167 - DS#refreshAll
- #168 - DS#inject - replace instead of merge.
onConflict: 'replace'
will replace existing items instead of merging into them.
Backwards compatible bug fixes
Updated less than a minute ago