mercredi 9 mars 2016

Properly create hasMany/belongsTo record in old ember js

Using emberjs 1.5.1. I have couple of models:

App.Queue = DS.Model.extend({
    queue_id:   attr('number', {}),
    services:   hasMany('service', {})
});

App.Service = DS.Model.extend({
    queue:      belongsTo('queue', {}),
    service_id: attr('number', {}),
});

Here I create queue instance, save it, then try to create service instance and put created queue in belongsTo field

var new_queue = controller.store.createRecord('queue', {queue_id: element.Item1.Id});
new_queue.save();

var new_service = controller.store.createRecord('service', {
                                    queue: new_queue,
                                    service_id: subelement.Item1.Id,
                                });
new_service.save();

and after this I get new_service instance with the queue field equals undefined. Any ideas appreciated




Aucun commentaire:

Enregistrer un commentaire