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

POST/PATCH with multi ids #1010

Closed
Amedeo91 opened this Issue Apr 10, 2017 · 0 comments

Comments

Projects
None yet
2 participants
@Amedeo91

Amedeo91 commented Apr 10, 2017

Hi all,

for my application I need to provide end-point as follow:
1 carts/<cart_id> --> datasource: carts
2 carts/<cart_id>/products/<product_id> --> datasource: products
3 carts/<cart_id>/products/<product_id>/details/<detail_id> --> datasource: details

My goal is to be able to do all the HTTP method (GET, PATCH, PUT, POST and the embedded resource solver) in using the parameter passed in the URL.

Note: <product_id> and <cart_id> are to be hidden from the client for details and only <cart_id> should be hidden for the products

Below some example:

  • endpoint 1: GET/DELETE search_filter= {id:<cart_id>}
    PUT/PATCH filter_to_update = {id:<cart_id>}
    POST add the query parameter to the request body = {id:<cart_id>}
  • endpoint 2: GET/DELETE search_filter= {cart_id:<cart_id>,id:<product_id>}
    PUT/PATCH filter_to_update = {cart_id:<cart_id>,id:<product_id>}
    POST add the query parameter to the request body = {cart_id:<cart_id>,id:<product_id>}
  • endpoint 3: GET/DELETE search_filter= {cart_id:<cart_id>,product_id:<product_id>, id:<detail_id>}
    PUT/PATCH filter_to_update = {cart_id:<cart_id>,product_id:<product_id>, id:<detail_id>}
    POST add the query parameter to the request body = {cart_id:<cart_id>,product_id:<product_id>, id:<detail_id>}

At the moment I was able to meet my requirement by both adding some hook event (pre_POST, pre_PATCH, pre_PUT) and some customization in the dataLayer.
However, I think it would be nicer to update Eve business logic (especially for the embedded documents).

Moreover, I reckon that the current behavior is kind-of buggy since I am able to POST a new element (i.e. a new product) and I am not able to GET it if the client does not explicitly provide the cartId at the product insert time.

The scenario above it is kind of usefull if the primary-key of our resource is made by more than only one field (therefore, {cart_id:<cart_id>,product_id:<product_id>, id:<detail_id>} should be a primary key for the details resource)

Could you please share with us what do you think about the above scenario?

Regards,
Amedeo

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment