AnthonyJClink
AnthonyJClink

Reputation: 1008

Using ember data how can I fetch children async individually?

The use case is quite simple, but I seem to be missing something.

This is my first real crack at ember, and the use case is strange... but any assistance would be welcome.

My store looks like this:

App.TroubleTicket = DS.Model.extend({
     'name'        : DS.attr('string'),
     'type'        : DS.attr('string'),
     'resolutions' : DS.hasMany('resolution', async : true);
});

App.Resolution = DS.Model.extend({
    'troubleTicket' : DS.belongsTo('troubleTicket', async : true);
    'description' : DS.attr('string');
});

The payload for the first is:

{
    "troubleTicket" : {
        "id"   : "TICKET-123",
        "type" : "Issue",
        "resolutions" : ["RES-123", "RES-321", "RES-213"]
     }
}

I get this payload just fine, however the expected behavior of this setup is that each of the resolutions is its own HTTP GET when rendering.

When this resource is requested, a get with query params is executed by JQuery, however the desired behavior is a new http.get for each of the resolution ids.

Any direction would be wonderful.

Upvotes: 0

Views: 70

Answers (1)

NicholasJohn16
NicholasJohn16

Reputation: 2409

Please upgrade your version of Ember-data. That feature was made default in Beta-9.

Upvotes: 1

Related Questions