I need to be able to grab a collection based on a collection of objects. For this, I'm considering a couple of approaches, but am not sure which one makes the most sense, so I'll post them both. If there is a better way that I may not have considered, then please feel free to post your suggestion(s) :)
For example, I'll use Products and Reviews (which are reviews of products) as resources.
Objective:We want to get the Reviews for all of the Products
Approach A:
POST api/Products { json: filters, limits, etc } // returns api/Products/<id>GET api/Products/<id>/Reviews { json: filters, limits, etc } // returns json array // ... of reviews present in products// id in this case would refer to the collection, which would be cached
Approach B:
GET api/Reviews { json: filters } // returns json array of reviews, but needs to // ... have either all of the product ids passed as an array (not practical with // ... huge collections), or needs to have all of the api/Products filters passed, // ... in which case making the code unDRY
Approach C:
GET api/Reviews { json: filters: { products: 'api/Products?filters' }...// is this reasonable?
Thanks in advance for any help, and apologies if this question is noob, I'm still new to REST
Approach D:
access individual productsGET api/Product/<id>access collection of products:POST api/Products?filters=stuff..GET api/Products/<id>access collection of products' reviewsPOST api/Products/<id>/Reviews?filters=stuffGET api/Products/<id>/Reviews/<id>... this would thus allow us to cache the result easily, does this seem reasonable to you?