vertx/src/main/java/eu/internetofus/common/vertx/Repository.java
/**
   * Count the aggregated documents that match the query.
   *
   * @param collectionName of the collections that contains the models.
   * @param elementPath    the splitted path of the elements.
   * @param query          to satisfy.
   *
   * @return the future of the total documents that match.
   */
Count the aggregated documents that match the query.
@param collectionName of the collections that contains the models.
@param elementPath    the splitted path of the elements.
@param query          to satisfy.

@return the future of the total documents that match.
Count the aggregated documents that match the query . @param collectionName of the collections that contains the models . @param elementPath the splitted path of the elements . @param query to satisfy . @return the future of the total documents that match .
protected Future<Long> countAggregation(@NotNull final String collectionName, @NotNull final String[] elementPath,
      @NotNull final JsonObject query) {
    final Promise<Long> promise = Promise.promise();
    final var countPipeline = new AggregationBuilder().unwindPath(elementPath).match(query).build()
        .add(new JsonObject().put("$count", "total"));
    this.pool.aggregate(collectionName, countPipeline).handler(element -> {
      final var total = element.getLong("total", 0l);
      promise.complete(total);
    }).exceptionHandler(cause -> {
      promise.fail(cause);
    }).endHandler(empty -> {
      promise.tryComplete(0l);
    });
    return promise.future();
  }
protected Future < Long > countAggregation ( @ NotNull final String collectionName , @ NotNull final String [ ] elementPath , @ NotNull final JsonObject query ) { final Promise < Long > promise = Promise . promise ( ) ; final var countPipeline = new AggregationBuilder ( ) . unwindPath ( elementPath ) . match ( query ) . build ( ) . add ( new JsonObject ( ) . put ( "$count" , "total" ) ) ; this . pool . aggregate ( collectionName , countPipeline ) . handler ( element -> { final var total = element . getLong ( "total" , 0l ) ; promise . complete ( total ) ; } ) . exceptionHandler ( cause -> { promise . fail ( cause ) ; } ) . endHandler ( empty -> { promise . tryComplete ( 0l ) ; } ) ; return promise . future ( ) ; }
Count the aggregated documents that match the query.
Count the aggregated documents that match the query .
// Use this complete when no documents match