ember-jsonapi-resources Module
This module provides the following classes:
This module is a rollup of the following modules:
-
adapter-api-host-proxy-mixin
Mixin to provide url rewrite for proxied api. Mostly used as example.
-
adapters
Adapter for a JSON API endpoint, use as a service for your backend
-
authorization
A Mixin class for storage of credential/token uses with a HTTP Authorization request-header The default solution is to use localStorage['AuthorizationHeader'] for the credential
-
cache
A Mixin class for caching JSON API resource objects
-
initializers
-
resource
A Resource class to create JSON API resource objects. This is abstract, first define a prototype using
Resource.extend({ type: entity })
. Model prototypes are registered in the container as factories, they use the options:{ instantiate: false, singleton: false }
. So, to create a model instance use the owner API method_lookupFactory('model:name')
† thencreate()
:`
js let model = Ember.getOwner(this)._lookupFactory('model:entity').create({ attributes: { key: value } });`
† **Note:** eventuallyfactoryFor
will replace_lookupFactory
See -
resource-operations
Mixin to provide interations between a Resource instance and service/adapter.
-
serializers
Serializer/Deserializer for a JSON API resource object, used by adapter. When extending use a mixin or define transform methods to serialize and/or deserializer attributes based on the name or the type of attribute. The methods use a naming convention: - '[de]serialize' + 'AttrName' or 'TypeName' + 'Attribute' - E.g. use
serializeNameAttribute
anddeserializeNameAttribute
in a generated serializer for use withname: attr()
- Or, redefineserializeDateAttribute
anddeserializeDateAttribute
to use your own data transformation withattr('date')
the default, Date type [de]serialize methods transfrom to/from ISO Format. - Transform methods based on the name of the attribute will be called instead of any transform methods based on the type of the attribute. -
store
Service for a JSON API endpoint a facade to your resource adapter
-
transforms
A Mixin class for methods to transform resource attributes, includes date attribute methods to serialize and deserialize the date(time) to/from ISO Format for use with
attr('date')
Any valid attribute type (string, boolean, number, object, array, date) can be added to your app, just generate a transforms mixin and define other types if needed, and use the type when defining a resource attribute, e.g. attr('array') -
utils
Abstract class to transform mapped data structures