Ember Data v1.0.0-beta.16 released

We are happy to announce the release of Ember Data 1.0.0-beta.16. It includes many bug fixes and some new features. As always, this version is available from npm (for ember-cli), rubygems or bower. Builds are also available as static files at emberjs.com/builds

Version 1.0.0-beta.16 represents the efforts of at least 31 contributors in 112 commits.

New core contributor

Contributor Christopher Persson Has been granted the status of a collaborator and will help us classify issues, merge pull requests, and contribute bug fixes and documentation. Christoffer is very active in classifying issues and contributing features and bug fixes to the Ember Data project.

Major changes

The store now passes snapshots instead of records to the adapter method

In 1.0.0-beta.15 Ember Data introduced the Snapshot API and began to pass snapshot instances to all serializers to prevent side effects when checking serialization relationships. This introduces some pain points in 3rd party adapters and serializers because they cannot easily create snapshot instances without using private APIs. In Ember Data 1.0.0-beta.16, the store will now pass the snapshot instance to the adapter method instead of recording the instance.

The following adapter methods now receive snapshots instead of recording:

  • find(store, type, id, snapshot)
  • findMany(store, type, ids, snapshots)
  • findHasMany(store, snapshot, url, relationship)
  • findBelongsTo(store, snapshot, url, relationship)
  • createRecord(store, type, snapshot)
  • updateRecord(store, type, snapshot)
  • deleteRecord(store, type, snapshot)

‘S signature buildURL(type, id, snapshot) It has also been updated to receive snapshots instead of recording.

This change eliminates the need for the adapter to manually create a snapshot using a private API record._createSnapshot() Ability to pass the snapshot to the serializer.

Snapshots are backward compatible with records (with deprecation warnings), and it should be very simple to update the current code to a public snapshot API:

post.get('id')           => postSnapshot.id
post.get('title')        => postSnapshot.attr('title')
post.get('author')       => postSnapshot.belongsTo('author')
post.get('comments')     => postSnapshot.hasMany('comments')
post.constructor         => postSnapshot.type;
post.constructor.typeKey => postSnapshot.typeKey

If you need to access the basic records of the snapshot, you can access snapshot.record.

Complete API reference DS.Snapshot Can be found Here.


Storage as a service

The store is now registered as a service. Therefore, when you use Ember Data 1.0.0-beta.16 in Ember 1.10+, you can now inject storage into any Ember object managed by the container.

App.TweetComposerComponent = Ember.Component.extend({
  store: Ember.inject.service(),
  newTweet: function() {
    return this.get('store').createRecord('tweet', {});

Please give warm thanks Martin Demus Thank him for his work to achieve this feature!

Mixin in polymorphic relationships

Igor Terzic Added support for using mixins in polymorphic relationships. This allows Ember Data to reference the Mixin instead of the Model class as the type parameter of the relationship.

App.Comment = DS.Model.extend({
  owner: belongsTo('commentable', { polymorphic: true })

App.CommentableMixin = Ember.Mixin.create({
  comments: hasMany('comment')

Better support for using multiple stores

James Murphy Landed
Great PR This makes it easier to use multiple stores in the Ember app.

Change log

In addition to the major changes mentioned above, this version also includes many bug fixes and documentation updates. Be sure to check the change log for a complete list of updates.

Leave a Reply

Your email address will not be published. Required fields are marked *