2 ms·
That's not a rest-y API. You want GET /orders?user=Id Orders can be searched on many dimensions, not inherent to users
by 8note 5y ago
That's not a rest-y API.
You want
GET /orders?user=Id
Orders can be searched on many dimensions, not inherent to users
- pan69 5y agoTrue. But it sort of depends on the kind of relationship "orders" has. E.g. "orders" is a good example to use your suggested GET /orders?user_id=:id and that is probably because an order has a many-to-many relationship, e.g. with users and products (i.e. an order doesn't belong to neither user nor product). However, take something like an "address" which might belong to a user (one-to-many), i.e. the user has ownership of the relationship with an address, in that scenario you probably want to use GET /users/:id/addresses But then again, when it comes to API's, domain modelling is the hard part and it is therefore the reason why you don't want to return nested results/objects.