ember-data-model-fragments
Advanced tools
Comparing version
# Changelog | ||
### v1.13.0 (October 25, 2015) | ||
* Removed deprecated APIs | ||
* Changed default value of fragment array properties to an empty array | ||
* Changed repository name | ||
##### Breaking Changes | ||
Deprecated APIs have been removed: | ||
* `DS.ModelFragment` → `MF.Fragment` | ||
* `DS.hasOneFragment` → `MF.fragment` | ||
* `DS.hasManyFragments` → `MF.fragmentArray` | ||
* `DS.fragmentOwner` → `MF.fragmentOwner` | ||
Support for non-fragment array properties has been added with the new property `MF.array`, which supports transforms: | ||
```javascript | ||
export default DS.Model.extend({ | ||
things: MF.array('string'), | ||
stuff: MF.array('my-custom-transform') | ||
}); | ||
``` | ||
The default value of fragment array properties is now an empty array (previously `null`): | ||
```javascript | ||
export default DS.Model.extend({ | ||
things: MF.fragmentArray('some-fragment'), // { defaultValue: [] } option is no longer necessary | ||
stuff: MF.array('string') // Defaults to an empty array as well | ||
}); | ||
``` | ||
The repository name has changed from `ember-data.model-fragments` to `ember-data-model-fragments`. This does not affect the NPM package name, but does affect the Bower package. Consequently, when upgrading from v0.4.x to v1.13.x, in addition to making sure the addon blueprint runs, the old Bower package must be removed manually: | ||
```sh | ||
$ bower uninstall --save ember-data.model-fragments | ||
``` | ||
### v0.4.4 (October 25, 2015) | ||
@@ -4,0 +43,0 @@ |
@@ -13,4 +13,4 @@ 'use strict'; | ||
var json = require('../../../package.json'); | ||
return this.addBowerPackageToProject('ember-data.model-fragments', json.version); | ||
return this.addBowerPackageToProject('ember-data-model-fragments', json.version); | ||
} | ||
}; |
var path = require('path'); | ||
module.exports = { | ||
description: 'Generates an ember-data.model-fragments model.', | ||
description: 'Generates an ember-data-model-fragments model.', | ||
@@ -6,0 +6,0 @@ anonymousOptions: [ |
@@ -10,4 +10,4 @@ 'use strict'; | ||
app.import({ | ||
development: app.bowerDirectory + '/ember-data.model-fragments/dist/ember-data.model-fragments.js', | ||
production: app.bowerDirectory + '/ember-data.model-fragments/dist/ember-data.model-fragments.prod.js' | ||
development: app.bowerDirectory + '/ember-data-model-fragments/dist/ember-data-model-fragments.js', | ||
production: app.bowerDirectory + '/ember-data-model-fragments/dist/ember-data-model-fragments.prod.js' | ||
}); | ||
@@ -14,0 +14,0 @@ |
{ | ||
"name": "ember-data-model-fragments", | ||
"description": "Ember Data addon to support nested JSON documents", | ||
"version": "0.4.4", | ||
"version": "1.13.0", | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/lytics/ember-data.model-fragments.git" | ||
"url": "https://github.com/lytics/ember-data-model-fragments.git" | ||
}, | ||
@@ -9,0 +9,0 @@ "author": "Steven Lindberg <steven@lytics.io>", |
# Ember Data Model Fragments | ||
[](https://travis-ci.org/lytics/ember-data.model-fragments) | ||
[](https://travis-ci.org/lytics/ember-data-model-fragments) | ||
[](http://badge.fury.io/js/ember-data-model-fragments) | ||
@@ -9,3 +9,3 @@ [](http://emberobserver.com/addons/ember-data-model-fragments) | ||
:warning: The API has changed significantly in preparation for v1.0. Deprecations have been added to all updated APIs with instructions on how to upgrade. | ||
:warning: Deprecated APIs have been removed. See the [changelog](CHANGELOG.md) for more information on breaking changes. | ||
@@ -23,3 +23,3 @@ ## Compatibility | ||
| >= v1.0.0-beta.15 <= v1.0.0-beta.18 | v0.3.3 | | ||
| >= v1.13.x | >= v0.4.x | | ||
| >= v1.13.x | >= v1.13.x | | ||
@@ -189,8 +189,8 @@ #### Notes | ||
name : MF.fragment('name', { defaultValue: { first: 'Faceless', last: 'Man' } }), | ||
addresses : MF.fragmentArray('address', { defaultValue: [] }), | ||
titles : MF.array('string', { defaultValue: [] }) | ||
addresses : MF.fragmentArray('address'), | ||
titles : MF.array('string') | ||
}); | ||
``` | ||
Since JavaScript objects and arrays are passed by reference, the value of `defaultValue` is copied using `Ember.copy` in order to prevent all instances sharing the same value. If a `defaultValue` option is not specified, both `MF.fragment` and `MF.fragmentArray` properties will default to `null`. Note that this may cause confusion when creating a record with a `MF.fragmentArray` property: | ||
Since JavaScript objects and arrays are passed by reference, the value of `defaultValue` is copied using `Ember.copy` in order to prevent all instances sharing the same value. If a `defaultValue` option is not specified, `MF.fragment` properties default to `null` and `MF.fragmentArray` properties default to an empty array. Note that this may cause confusion when creating a record with a `MF.fragmentArray` property: | ||
@@ -240,2 +240,4 @@ ```javascript | ||
Since fragment deserialization uses the value of a single attribute in the parent model, the `normalizeResponse` method of the serializer is never used. And since the attribute value is not a full-fledged [JSON API](http://jsonapi.org/) response, `DS.JSONAPISerializer` cannot be used with fragments. Because of this, auto-generated fragment serializers **do not use the application serializer** and instead use `DS.JSONSerializer`. If common logic must be added to auto-generated fragment serializers, apps can register a custom `serializer:-fragment` with the application in an initializer. | ||
If custom serialization of the owner record is needed, fragment [snapshots](http://emberjs.com/api/data/classes/DS.Snapshot.html) can be accessed using the [`Snapshot#attr`](http://emberjs.com/api/data/classes/DS.Snapshot.html#method_attr) method. Note that this differs from how relationships are accessed on snapshots (using `belongsTo`/`hasMany` methods): | ||
@@ -242,0 +244,0 @@ |
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
25995
7.82%1
-50%475
0.42%