vendredi 26 août 2016

Ember can't use data from store

Hey so im having a problem using ember-data and can't seem to find the solution anywhere. Essentially the problem is that I am passing an object that contains 3 objects which each contain on array of objects (which are a a different model). I know that the backend is passing the data correctly because I can see it in the network tab of the console:

network tab

Here is what 'app/routes/dashboard.js' looks like:

    import Ember from 'ember';

    export default Ember.Route.extend({
        model: function() {
            var tmp = this.store.findQuery('series', {view: 'dashboard'});
            console.log(tmp);
            return tmp;
        },

        setupController: function(controller, models) {
            controller.set('model', models);
        }
    });

Heres what my 'app/serializers/application.js' looks like:

      import DS from 'ember-data';

      export default DS.JSONSerializer.extend({
         primaryKey: '_id'
      });

And this is what the series model looks like:

    import DS from 'ember-data';

    export default DS.Model.extend({
        awesome: DS.hasMany('video'),
        boring: DS.hasMany('video'),
        funstomp: DS.hasMany('video')
    });

And in the video model I added: 'series: DS.belongsTo('series')'. But when I try to print out the model in the dashboard controller (ie. console.log(this.get('model'));) all I get is this:

log

As you can see I can't seem to find the awesome/boring/funstomp objects anywhere. And the content is just an empty array, so not sure where anything is. Any help is greatly appreciated, thanks.




Aucun commentaire:

Enregistrer un commentaire