Generate Uni from Multi response of database after applying business logic #921
-
Hi, Inside a rest function I'm making a reactive Postgres Db call which is returning a Multi. My intention is to run a complex business logic on Multi and return a new Uni based on the output of the business logic.
|
Beta Was this translation helpful? Give feedback.
Answered by
cescoffier
May 15, 2022
Replies: 1 comment 1 reply
-
You need to collect the items into a Map. In the end, you will have something like: Multi<Object1> objects = DB.getAll(dbClient);
return Uni<Map<String, String>> uni =
multi.collect()
.asMap(item -> getUniqueKeyForItem(item)); // Put the computed key and the item to the Map |
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
abnayak
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You need to collect the items into a Map.
See https://smallrye.io/smallrye-mutiny/guides/collecting-items#collecting-items-into-a-map.
In the end, you will have something like: