Indicia-Team / warehouse

GNU General Public License v3.0
5 stars 3 forks source link

Enable REST GET of multiple entities by ID #511

Closed kazlauskis closed 7 months ago

kazlauskis commented 7 months ago

Occasionally, a feature must fetch multiple entities, e.g. samples, locations, groups, etc., by their IDs. To do that, we currently do multiple/locations/:id GET queries, which isn't efficient and makes it harder to keep the whole operation "transactional" if any fail. It would be useful if one could specify all the matching entity IDs using the REST API in a single request, like /locations?id=123,456,789.

johnvanbreda commented 7 months ago

Is this still a requirement now that you have GET groups/{id}/locations?

kazlauskis commented 7 months ago

Having this as a general feature for all entities would be helpful, but it isn't necessary anymore, so I am closing this for now.

Regarding fetching locations for groups, a useful option would be if the /locations endpoint returned entities with the matched group IDs, group_id=[123, 234], so I could fetch the locations with their custom attributes then. Again, this is not an immediate requirement, and I can get away with the groups/{id}/locations for now.