I have a UserSession model defined as such:
App.UserSession = DS.Model.extend({
authToken: attr('string'),
firstName: attr('string'),
lastName: attr('string')
});
When a user is logging in, I'm making an AJAX POST request to my back-end which return a JSON representation such as:
{
"user_session": {
"id": 1,
"auth_token": "token_here",
"first_name": "John",
"last_name": "Doe"
}
}
Now normally, if I were to do the following, Ember Data would take care of automatically serializing the JSON and adding the object:
App.UserSession.find(<session-id>);
When I'm making a manual AJAX call though, is there an easy way to load the JSON returned into an Ember Data store object without having to manually deserialize it?
Edited for clarity:
The below does not work, but I'm hoping to find some function that does what's described above, which may look similar to the call below.
App.UserSession.load(<session-json>);
id
property. – MilkyWayJoe