(JSBIN) (JSBIN output) So, I have the following model and I would to load my data:
App.List = DS.Model.extend({
name: DS.attr('string')
});
App.User = DS.Model.extend({
username: DS.attr('string'),
users: DS.belongsTo('App.List') // is this line correct?
});
App.List.reopen({
users: DS.hasMany('App.User')
});
I have my own custom adapter configuration:
DS.SocketAdapter.configure('App.User',
{sideloadAs: 'users'}
);
I would to boostrap my model with the following payload:
{
"list" : {"id" : 1, "name" : "Nome", "users" : [1,2] },
"users": [
{ "id":1, "username": "user1", "users": 1 },
{ "id":2, "username": "user2", "users": 1 }
]
}
From console I type:
obj = ' { "list" : {"id" : 1, "name" : "Nome", "users" : [1,2] }, "users": [{ "id":1, "username": "user1", "users": 1 },{ "id":2, "username":"user2", "users" : 1}] } ';
obj = JSON.parse(obj);
DS.get('defaultStore').load( App.List, obj);
var l_len = App.List.find().get('length');
var u_len = App.User.find().get('length');
console.log( ">>>>>>> "+ l_len + "record(s) " +u_len + "record(s)");
But it seems that no data was loaded. I am testing this model from console. I am using ember-data revision 12. Where is wrong in my code?
ps
SocketAdapter extends RESTAdapter.
Should I boostrap my data inside my custom Adapter? If yes, I don't know where put my code (if inside findMany
, findAll
redefinition). Thanks for help!
(JSBIN) (JSBIN output)