I am exploring this beautiful tool/framework. There is scenario I need to implement and do not understand how.
/companies/
/companies/{companyId}
/users/
/users/{userId}
However it is many-to-many relationship between companies and users.
In order to get users from companies or add/remove user to company I need use following methods
GET|POST|DELETE /companies/{companyId}/users
Or we can retrieve list of companyIds to which company belong using following API request
GET /users/{userId}/companies
And now I need to implement management of user who works in companies. I would like to have a Tabbed form on edit with Users that will display lists of users belong to company GET /companies/{companyId}/users and allow to add remove from this resource.
The REST requests from admin-on-rest don't deal with nested resource. That means it's the responsibility of your REST client to turn something like:
GET_LIST companies { filter: { userId: 123 } }
into something like:
GET http://path.to.my.api/users/123/companies
As for displaying a list of related records in edit view, check out <ReferenceManyField>.
And what about accessing a nested resource via the URL?
What I mean is:
My API returns a single comment with the request GET /posts/{postId}/comments/{commentId}
But I can't wrap my head around it how to get this request from a resource.
But maybe this is just bad design from my API? And it should return the comment without the parent post?
You just need to map that in your restClient. You'll receive requests looking like:
GET_LIST comments {"filter":{"post_id":{postIt}, "pagination":{"page":"1","perPage":"6"},"sort":{"field":"id","order":"DESC"}}
It's up to you to map that to your REST API route
GET /posts/{postId}/comments/
Will admin-on-rest understand URLs like example.com/#/companies/{companyId}/users{userId}/show in the browsers address bar?
@simonschllng no, that's not planned.
Most helpful comment
The REST requests from admin-on-rest don't deal with nested resource. That means it's the responsibility of your REST client to turn something like:
GET_LIST companies { filter: { userId: 123 } }into something like:
GET http://path.to.my.api/users/123/companiesAs for displaying a list of related records in edit view, check out
<ReferenceManyField>.