4 ms·
> Here are some bad examples : > /retreiveClientByOrder?orderId=1 I note the author didn't go on to demonstrate a better way of doing this. What would he rec
by josai 12y ago
> Here are some bad examples :
> /retreiveClientByOrder?orderId=1
I note the author didn't go on to demonstrate a better way of doing this. What would he recommend, /clients?by_order_id=1 ?
- misja 12y agoUsing sub-resources, you get something like this: GET /orders/1/clients
- jagger27 12y agoSo mapping this request onto a SQL database would be something like... SELECT * FROM orders WHERE client_id = 1 And for GET /clients/1/orders it seems like in practice it would be the same relation since it would be wasteful to store two tables. Is this roughly correct?
- mattmanser 12y agoNo. Think of it as "for order 1 list all clients", so it would be: SELECT * FROM clients WHERE client_id IN (SELECT client_id FROM orders WHERE order_id = @order_id) The GET /clients/1/orders is what would result in your query (for client 1 list all orders).