Ember noob here -
I have two models with a hasMany relationship like below -
var Season = DS.Model.extend({
name: DS.attr('string'),
periods: DS.hasMany('period', {
async: false
})
});
var Period = DS.Model.extend({
from: DS.attr('date'),
to: DS.attr('date'),
season: DS.belongsTo('season')
});
A Season can exist without any Periods - This is how I create a Season record and save --
var season = this.store.createRecord('season', {
name: name
});
season.save().then(function(season){
/* season saved */
});
The POST request payload looks like this --
{
"season" : {
"name" : "test"
}
}
But the backend API expects the payload to be like this -- with an empty periods array
{
"season" : {
"name" : "test"
"periods" : []
}
}
How do I achieve this?
Aucun commentaire:
Enregistrer un commentaire