'Jave webflux process a String-response with id's
I've a reactive API which receives the following String (image below). I want to process these ID's and perform a search query to my MongoDB and return a Flux with my model (filled with the ID's which existed in the database)
The code I got till now is:
public Mono<ServerResponse> findAllSpeakersBySessionId(ServerRequest request) {
Flux<String> listWithIds = request.bodyToFlux(String.class);
return ServerResponse.ok()
.contentType(MediaType.APPLICATION_JSON)
.body(speakerService.findAllByIds(listWithIds), String.class);
}
public Flux<Speaker> findAllByIds(Flux<String> speaker_Ids) {
return this._speakerRepository.findAllById(speaker_Ids);
}
I'm new to this reactive programming and trying to get an understanding of it. How would I process this String-response so it looks up those ID's and returns me a Flux
Speaker-class
@Getter
@Setter
@NoArgsConstructor
@AllArgsConstructor
public class Speaker {
@Id
private String speaker_id;
@NotNull
private String name;
private String skills;
private String company;
private String biography;
private String specialisation;
private List<String> session_Ids;
}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|