Created
September 25, 2022 10:59
-
-
Save GayanM/61cbc361895365017605c9526267a71a to your computer and use it in GitHub Desktop.
Obtain a data map with order id and order’s product count
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@RequestMapping("/products-count") | |
public Map<Long, Integer> getOrdersWithProductCount() { | |
return orderRepo.findAll().stream(). | |
collect(Collectors.toMap(o -> o.getId(), o -> o.getProducts().size())); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment