In 'plain vanilla' MongoDB, methods that do a write operation into the DB, such as .insertOne() or .deleteOne(), will return an InsertOneResult or DeleteResult respectively. These objects will return a boolean value for acknowledged and an id where applicable. This allows us to ensure that the write operation was successful.
However, in Panache, the MongoOperations.class is returning void:
MongoOperations.class
private static void persist(MongoCollection collection, Object entity) {
collection.insertOne(entity);
}
The question then is, how can we retrieve the resulting InsertResult and DeleteObject object?
pom dependency being used
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-mongodb-panache</artifactId>
<version>1.5.0.Final</version>