-
Notifications
You must be signed in to change notification settings - Fork 156
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
the hasMany relations get removed on reload #38
Comments
The newest version of the localstorage-adapter is meant for Ember Data beta 5 and onwards. I would consider upgrading. Also make sure you have the newest version of master. |
i tried with latest version of ember-data(i.e. ember data beta 6) and even latest version of master but having same problem |
@oblongta I believe that if Also, this is wrong: // you need to use the store to create a record,
// not a model (which is an array in this case)
var a=model.get('employees');
a.createRecord(); Do this instead var person = this.store.createRecord('person', {
name: 'pqr',
department: 'lmn',
});
person.save().then(function(person) {
person.set('company', model);
person.save();
}); I ask you to do this because I recently had problems with embedding relations in |
ok then how do i add person to a company which has hasMany relation with the person?? And my code is update version of this jsbin if you look closely: |
This is how I do it for a project of mine:
Don't get confused with my use of App.get('currentUser') just think of it as your person. You could potentially have created this person already. But the above code saves the records and maintains the hasMany relationship. My relationships are:
|
Thanxx, and my error is same as #23 as it seems to me. |
I tried this and getting the same problem: var p=this.store.createRecord('person',{ p.save().then(function(p){ |
Ah, now I remember why. I'll have to take a look at it. But try using findAll instead of find. |
no findAll doesnt solve the issue. |
Okay, I know now. As the README states: Include
In the code you linked initially there is no ApplicationSerializer. This serializer handles all the relationships, so without it you're never going to get the relationships. I will have a closer look at find() since I still expect it to be a little buggy, so use findAll for now. |
Thanks for help. |
I have define one to many relationship between company and person.The records are successfully added and saved.However on reload the hasMany arrays content gets wiped out and hence all the relations get lost.
I am using ember-data-beta-1 and ember-data local storage adapter.
And my code is:
and my index.html file is:
<title>json method#1</title>The text was updated successfully, but these errors were encountered: