-
Notifications
You must be signed in to change notification settings - Fork 76
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
hasMany relationship not updating from the belongsTo side. #116
Comments
You have to save the parent record as well. This isn’t typical for Ember Data, but it’s required in this case to save both ends of the relationship. The documentation should be updated to reflect this. But people expecting behaviour like with other Ember Data adapters will not expect it. (For background on this, see #16) |
Thanks for pointing me towards that. However it seems that even if I do that, it still leaves the array empty on the item side. I tried an approach similar to what you did in your initializer (mine in a component). |
Are you saving the That code you linked to is pretty old, but I have this more recent acceptance test that constructs related objects. With the code you have in your first comment, you could do something like this at the end of |
Sorry for the lack of code. My computer is running offline for the moment. I did exactly as you mentioned and it is still not working. I'm beginning to wonder if there is an issue with my models or the way i set up ember pouch. The strange part is that the discount is getting the item id. |
Because this should be working, i will start a project from scratch tomorrow to test the functionality out and make sure it is isolated to this... I'll use the same ~version that you used in your adventure project, and rip off your ember pouch configs to make sure i didn't do something dumb. |
Okay, so I started from scratch, not using the same version as you, however 2.4 is supposed to be minor fixes and backwards compatible. Our adapters are almost identical (I added debugging to mine), and our config/environment files are similar in regards to ember-pouch. It appears that it is still not working, so this disproves my configs being bad theory. As you can see here, my approach is pretty spot on to what you mentioned earlier. As before, the discount is getting the ID, but no matter how I save it (order wise), the Item won't update it's reference to the discount. |
Just an update, I swapped ember-pouch out with emberfire (firebase) and the way I'm writing it seems to work there. I tried troubleshooting ember-pouch earlier, but my knowledge of both emberjs and ember-pouch are limited. I would like to investigate further, but it may be a while if at all before I get back to it. Unfortunately at the moment I need to get a prototype out. |
I figured out what’s missing! Your application doesn’t implement the
I’ll look at adding this to the documentation and/or addon default imports. |
Including the serialiser by default would preclude people having to define it themselves and avoid confusion such as in #116. But it could be installed manually with a generator, as well.
Thank you, that did it! I owe you a beer or something! I'm looking into adding to the documentation regarding saving both the child and parent for relationships, not sure where the best place for it would be though. I'm thinking probably before the "EmberPouch Blueprints" section. I will mull it over tonight, and create a pull request in the morning. I might open an issue for discussion on the documentation regarding organization and ordering. |
It appears that the hasMany relationships are not updating when a belongsTo record is created.
The two models i am using are:
and
I am attempting to add a discount to an existing item with the following code:
According to the ember docs, this should "just work". In the database, I can see that discount record has the id of the item that it was attached to. However the item record just contains an empty array, instead of an array with a reference to the discount record.
I am using:
Ember 2.4.1
ember-data 2.4.0
ember-pouch 3.1.1
The text was updated successfully, but these errors were encountered: