Documentation / @warp-drive/legacy / serializer / Serializer
Class: Serializer
Defined in: warp-drive-packages/legacy/src/serializer.ts:144
⚠️ 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
EmberObject
Constructors
Constructor
new Serializer(owner?): Serializer;
Defined in: node_modules/.pnpm/[email protected]/node_modules/ember-source/types/stable/@ember/object/index.d.ts:22
Parameters
owner?
Owner
Returns
Serializer
Inherited from
EmberObject.constructor
Methods
normalize()
normalize(_typeClass, hash):
| EmptyResourceDocument
| SingleResourceDocument;
Defined in: warp-drive-packages/legacy/src/serializer.ts:270
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
| EmptyResourceDocument
| SingleResourceDocument
Properties
store
store: Store;
Defined in: warp-drive-packages/legacy/src/serializer.ts:145