-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Add support for nested REST resources #186
Comments
+1 for this but i will suggest you look at how you can make your work an enhancement of pull request #57: which specified a namespace for the REST adaptor which is added to all the ajax URLs. Also see pull request #39, which does something nearer to the enhancement you are proposing but was abandoned in favour of #57 which unfortunately didn't go all the way to address the issue you are trying to fix. |
+1 App.Comment = DS.Model.extend({
post: DS.belongsTo('App.Post', {nested: true})
}); Note the |
I have a commit at twalpole@239ad99 that implements @justinko suggested method of specifying the nested hierarchy and produces the correct nested urls for create, update, delete (along with tests)- It does not yet work for the read since the location of where the fetch comes from is lost going through the store. I'm trying to figure out the best way to handle the read/fetch portion, if anyone has any suggestions I'd be more than happy to implement. |
@twalpole 👍 👏 |
👏 good progress @twalpole |
ok - I've added in read support too and submitted it as pull request #257 . Theres probably some refactoring that could be done to clean it up a little bit but I want to get some other eyes on it to see what I missed. |
👍 |
+1 |
@boy-jer For what it's worth, "voting" doesn't really hold any value in these discussions. |
@wagenet, in principle i agree with you but for what it's worth, having large enough people indicate their interest could make you, @tomdale , @wycats and any other key person like @ebryn to add your views and say yes or no in one fell swoop and everyone can move on, so that was the whole essence of the voting call. |
+1 |
+1 Support to create a hasOne would be awesome, too. For example: with |
r u the one? |
As a workaround, my pull request below adds the ability to create a nested url (using the parent record) So in your example ... /users/1/posts/ would return all the posts for user with a pk of 1 It would still require a custom adapter as the default RESTAdatper does not support this (the very reason for this pull request as I understand it). But it has worked for me -my django adapter does this today as the default REST backend requires hasMany lookups to use this approach instead of what you get out of the box w/ ember-data https://github.com/toranb/ember-data-django-rest-adapter |
Nice! I'll have a look at it... |
Any progress here? |
Would be great to have nested REST resources. Any progress? |
+1 |
+2 |
+3 |
+1 |
To the people that keep upvoting this, I had put an updated version as PR 790 - but the powers that be decided it was not the approach they wanted to follow. |
Then, IMHO, a clear and official statement somewhere in the guides would be helpful. |
+1 on the clear & official statement request |
Sorry for starting and abandoning! |
+1 |
1 similar comment
+1 |
+1 |
@sidonath PR looks promising. Is there any chance it will get merged? |
+1 |
2 similar comments
+1 |
+1 |
There's a worthwhile comment here: http://discuss.emberjs.com/t/i-was-being-silly-to-fight-ember-data-on-nested-urls-i-think/2082. |
The I'll keep it in mind going forward. |
This is not solved yet!?!?!?!? So many reason to stop using Ember - after weeks of development around nested Routes and now EmberData ignores the nesting! I have yet to see how this is better than Backbone or Angular |
That is funny. After reading dozens of blogs and github issues, I am starting to believe that the Nesting is only a client side routing mechanism and the REST API should not used nesting (there could be 100's of possible combinations of nesting for a relational model). So I will change the server. |
@cwiese FWIW, I have a large Ember project that uses a nested API that goes several layers deep. This is accomplished in our JSON with each returned parent object containing a I haven't had any problems with this structuring and it works well enough for what we're doing. We structure our JSON close to the JSONAPI format with the REST adapter. We are looking at switching to the JSONAPI adapter/serializer for ember-data. |
Great info - I did see that solution. Thanks |
I've seen a couple of discussions about this, and it seems no satisfactory outcome yet?
We've put together a little change to the standard RESTAdapter, that supports custom URLs. I'd like some opinions on it: If you like it, I'll update the tests and RESTAdapter and put in a pull request.
So, you can now define a custom resource URL in your model (I don't think this is the right place, but I couldn't think of a better way).
And the RESTAdapter checks for this custom URL.
NOTE: We're only using this for our CREATE action, so it'll need some tweaking to work for all actions. I'm happy to do all that if this has a chance of getting merged.
The text was updated successfully, but these errors were encountered: