Transforms
In Ember Data, attr
defines an attribute on a Model. By default, attributes are passed through as-is, however you can specify an optional type to have the value automatically transformed. Ember Data ships with four basic transform types: string
, number
, boolean
and date
.
You can define your own transforms by subclassing Transform. Ember Data transforms are normal TypeScript classes. The return type of deserialize
method becomes type of the model class property.
You may define your own transforms in TypeScript like so:
Note that you should declare your own transform under TransformRegistry
to make attr
to work with your transform.
Last updated