DS.Serializer Class addon/serializer.js:7
DS.Serializer
is an abstract base class that you should override in your
application to customize it for your backend. The minimum set of methods
that you should implement is:
normalizeResponse()
serialize()
And you can optionally override the following methods:
normalize()
For an example implementation, see DS.JSONSerializer, the included JSON serializer.
normalize
(typeClass, hash)
Object
The normalize
method is used to convert a payload received from your
external data source into the normalized form store.push()
expects. You
should override this method, munge the hash and return the normalized
payload.
Parameters:
- typeClass DS.Model
- hash Object
Returns:
- Object
normalizeResponse
(store, primaryModelClass, payload, id, requestType)
Object
The normalizeResponse
method is used to normalize a payload from the
server to a JSON-API Document.
Parameters:
Returns:
- Object
- JSON-API Document
serialize
(record, options)
Object
The serialize
method is used when a record is saved in order to convert
the record into the form that your external data source expects.
serialize
takes an optional options
hash with a single option:
includeId
: If this istrue
,serialize
should include the ID in the serialized object it builds.
Parameters:
- record DS.Model
- options [Object]
Returns:
- Object
store
{DS.Store}
public
The store
property is the application's store
that contains all records.
It's injected as a service.
It can be used to push records from a non flat data structure server
response.