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

[DOC]: default behaviour of serializers/json shouldSerializeHasMany method #5516

Merged
Merged
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
11 changes: 9 additions & 2 deletions addon/serializers/json.js
Original file line number Diff line number Diff line change
Expand Up @@ -135,8 +135,8 @@ const JSONSerializer = Serializer.extend({
});
```

You can also remove attributes by setting the `serialize` key to
`false` in your mapping object.
You can also remove attributes and relationships by setting the `serialize`
key to `false` in your mapping object.

Example

Expand All @@ -163,6 +163,10 @@ const JSONSerializer = Serializer.extend({

Note that the `admin` is now not included in the payload.

Setting `serialize` to `true` enforces serialization for hasMany
relationships even if it's neither a many-to-many nor many-to-none
relationship.

@property attrs
@type {Object}
*/
Expand Down Expand Up @@ -845,6 +849,9 @@ const JSONSerializer = Serializer.extend({
/**
Check if the given hasMany relationship should be serialized

By default only many-to-many and many-to-none relationships are serialized.
This could be configured per relationship by Serializer's `attrs` object.

@method shouldSerializeHasMany
@param {DS.Snapshot} snapshot
@param {String} key
Expand Down