vendredi 5 février 2016

Ember data - access model ID field?

In Ember, I need to store a model's ID in the session service. I'm not quite sure how to go about doing this, since IDs are seemingly not exposed and doing something like

export default DS.Model.extend({
    id                      : DS.attr('number'),
    loginname               : DS.attr('string'),
    /* ... */
});

gives an error:

Error: Assertion Failed: You may not set id as an attribute on your model. Please remove any lines that look like: id: DS.attr('<type>')

I need the model's ID persisted in the session along with all the other attributes, though.

I'm on ember 2.3.0, ember-data 2.3.0

How can I achieve this? I'm thankful for any pointers!

Aucun commentaire:

Enregistrer un commentaire