Open dalssoft opened 3 years ago
I think express understand the /item?ids=1,2,3
different then /item/123
What do you think about we merge this feature with https://github.com/herbsjs/herbs-cli/issues/21 issue?
My idea is create the getAll route with a query filter, e.g:
/customer?id=1,id=4,id=90
//or
/customer?age=19,company=microsoft,skill=node
this will returned a paginated result for me, I think it make sense because getByID
is by ID
and not by IDs
, it makes sense because it use an opened filter to query by many ids, it's the filter job
I think express understand the /item?ids=1,2,3 different then /item/123
yes. but there should be a way to get one or multiples IDs. The REST way of doing it may differ between approaches.
I prefer /items?ids=1,2,3
, but it is subjective.
Anyways, both /items/1
and /items?ids=1,2,3
should just use one UC: Find By IDs
/customer?age=19,company=microsoft,skill=node
That is another use case for search (ex: Search Customer
). I don't think it should be the same use case as Find By IDs
.
Anyways, both /items/1 and /items?ids=1,2,3 should just use one UC: Find By IDs
I think it will be a little bit hard to implements because:
/items
route already will be used by getall
usecase, we will need to add a middleware to check if it have a query, check if this query only has IDS sooo send this request to findByIds
UC, I think it's will look a smell pattern/code in the APIWhen we implements it into getAll
or search
route, we don't will need to implement a middleware rule to validate if exists query and if this query only have id property, we just implements the normal flux via getAll UC /items?id=123,id=234,id=34
sorry, I got it wrong. the correct argument would be:
both /items/1
and /items
should just use one UC: Find [Entity].
todo list on herbs
already do that: https://github.com/herbsjs/todolist-on-herbs/blob/master/src/infra/api/rest/routes.js#L6
apart from the naming, this issue rises a problem with being able to get multiples IDs from REST.
This issue highlits
/item/
(all),/item/?ids=1,2,3
(multiples) and/item/2
(single)It is still needed:
/item/
(all),/item/?ids=1,2,3
(multiples) and/item/2
(single)current:
getByIdItem.js
:should be:
findItemByIDs.js
: