jeudi 21 avril 2016

Ember.js data records shows content: null in relationships inspector

I have the following code in my 'user.js' model in ember-data:

export default DS.Model.extend({
  organization: DS.belongsTo('organization'),
  //other stuff
});

The CRUD for the website is working as expected, and in MongoDB I can see the following for the organization field of User:

"organization" : ObjectId("571974742ce868d575b79d6a"),

BUT, and I'm not sure if this is an error in my code or me not understanding how Ember-data works, I cannot access that ID from a model hook like so:

model(){
        return this.store.findRecord("user", this.get("session.currentUser.id"))
            .then(user => this.store.findRecord("location", {organization: user.organization}));
    }

And if I go to the Ember inspector to observe the belongsTo attribute of the User object, I see:

organization: <(subclass of Ember.ObjectProxy):ember956>

But clicking through I see content: null

What am I doing wrong? Could it be a server-side error?




Aucun commentaire:

Enregistrer un commentaire