Skip to content Skip to sidebar Skip to footer

Ds.fixtureadapter Loses Fixture Data With Hasmany Async Attributes

Background I've already submitted a github issue with the Ember Data team, but I'd love insight into how to work around this (or if I was mistaken all along) You can see a working

Solution 1:

I figured it out. The problem is in my implementation of findHasMany. The system expects an array of vanilla data objects, like:

[{id: 'doe-jr', name: 'john jr', grade: '4th'}]

when what I was actually returning was an array of App.Kid models.

Modified method is below:

findHasMany: function(store, record, link, relationship) {
    var type = relationship.type;
    var parentId = record.get('id');
    return store.findAll(relationship.type).then(function(children) {
        var content = children.get('content');
        var filteredContent = content.filter(function(child) {
            return (child.get('id').indexOf(parentId) == 0);
        });
        // Fixed the issue by pulling out the raw data from the fixture model // and returning that.vardata = filteredContent.map(function(content) {
            return content.get('data');
        });

        return Ember.RSVP.resolve(data);
        // Switch that return statement to the following to show original bug:// return Ember.RSVP.resolve(filteredContent);
    });
},

Post a Comment for "Ds.fixtureadapter Loses Fixture Data With Hasmany Async Attributes"