Java Springboot Reactive repository - Difference between myReactiveRepository.insert(myMono) and myMono.flatmap(myRepository::save)

Viewed 53

Small Spring Boot question on reactive repository, and how to "add a data entry" (purposely not using "save" or "insert" here) into a reactive repository please.

on a small example:

Mono<MyPojo> myPojoMono = someMono.map(oneElement -> doSomethingToConvertOneElementToMyPojo(oneElement));
//I would like to "add" myPojoMono into my reactive database

I came across the two reactive API reactiveRepository.insert(myMono) versus myMono.map(reactiveRepository::save)

What is the difference?

When to use which one?

May I ask why please?

What would be the correct method in my case where I just want to "add" the element into my database please (maybe not even save/insert)?

Thank you

0 Answers
Related