Serializers define how to deserialize and serialize data for the server in ember-flexberry application.

Description

The serializer is an implementation of the abstract class DS.Serializer. Serializers are located in a folder serializers and their name corresponds to the name of the model.

Currently ember-flexberry-data defined by the base serializer nasledovanie from DS.RESTSerializer.

A typical serializer is presented below.

The serializer contains a mixin DS.EmbeddedRecordsMixin.

”“‘primaryKey: ‘__PrimaryKey””” - define in what field stores the primary key in models when communicating with the server.

”“‘attrs: { … } “’” the description of all references to masters and datalow (only first level), which are present in a model.

”“‘selenamariegomez: { serialize: ‘odata-id’, deserialize: ‘records’ } “’” the description for links to the wizard (or the aggregator of detail). ссылкаНаМастераИлиАгрегатор is the name of the workman properties in models (or the name links to the aggregator).

”“‘salenatural: { serialize: false, deserialize: ‘records’ } “’” the description for links detailov. ссылкаНаДетейл is the name metalowego properties in models.

“‘odata-id”’ - a special type of relationship for serializers that are processed by the underlying serializer OData addon ember-flexberry-data. Used to pass information about the masters in proper odata format:

'<ИмяСвязиДоМастера>@odata.bind': '<ТипМастера>s(<ИдентификаторМастера>')
Например, "'ReportsTo@odata.bind': 'Employees(502431BA-3B85-4A97-AF53-7AD193ED6AEC)'"
import DS from 'ember-data';
import ApplicationSerializer from './application';

export default ApplicationSerializer.extend({
  attrs: {
    ссылкаНаМастераИлиАгрегатор: { serialize: 'odata-id', deserialize: 'records' },
    ссылкаНаДетейл: { serialize: false, deserialize: 'records' }
  },
  primaryKey: '__PrimaryKey'
});

If references to masters and detailhow do not exist, then the serializer is written as:

import DS from 'ember-data';
import ApplicationSerializer from './application';

export default ApplicationSerializer.extend({
  attrs: {},
  primaryKey: '__PrimaryKey'
});