I have an example project written with Micronaut, RxJava3, Vertx PgClient.
I try to use the following to insert a list of data.
public Single<Integer> saveAll(List<Post> data) {
var tuples = data.stream()
.map(d -> Tuple.of(d.title(), d.content()))
.toList();
return client.preparedQuery("INSERT INTO posts (title, content) VALUES ($1, $2)")
.rxExecuteBatch(tuples)
.map(SqlResult::rowCount);
}
In the
DataInitializer class, I used to initialize some sample data, but the result of `saveAll` always return 1 in the log.