jeudi 25 février 2016

Ember.js JSONApi, serializers, nested models

How could I serialize just created model with just created related models? Example:

import DS from 'ember-data';

//model "list"
export default DS.Model.extend( {
  contacts: DS.hasMany('contact')
});

//model "contact"
export default DS.Model.extend( {
  numbers: DS.hasMany('phone-number'),
  list: DS.belongsTo('list')
});

//model "phone-number"
export default DS.Model.extend( {
  numbers: DS.belongsTo('contact')
});

When a user creates new list with phone numbers I'd like to get whole information threw the list.serialize() method and next parse it on server side (rails), what is the right way to do that?

Ember 2.3 Ember-data 2.3 JsonApi




Aucun commentaire:

Enregistrer un commentaire