Documentation / @ember-data/serializer / index / default
Class: default
Defined in: warp-drive-packages/legacy/declarations/serializer.d.ts:130
⚠️ CAUTION you likely want the docs for MinimumSerializerInterface as extending this abstract class is unnecessary.
Serializer
is an abstract base class that you may 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 the included JSONSerializer.
Serializer
Extends
unknown
Constructors
Constructor
new default(): Serializer;
Returns
Serializer
Inherited from
EmberObject.constructor
Methods
normalize()
normalize(_typeClass, hash):
| SingleResourceDocument
| EmptyResourceDocument;
Defined in: warp-drive-packages/legacy/declarations/serializer.d.ts:253
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.
Example:
Serializer.extend({
normalize(modelClass, resourceHash) {
let data = {
id: resourceHash.id,
type: modelClass.modelName,
attributes: resourceHash
};
return { data: data };
}
})
Parameters
_typeClass
hash
Record
<string
, unknown
>
Returns
| SingleResourceDocument
| EmptyResourceDocument
Properties
store
store: default;
Defined in: warp-drive-packages/legacy/declarations/serializer.d.ts:131