vertx/src/main/java/eu/internetofus/common/vertx/Repository.java
/**
   * Search for a page.
   *
   * @param collectionName of the collections that contains the models.
   * @param query          to obtain the components of the page.
   * @param options        to apply to the search.
   * @param resultKey      to store the found models.
   * @param map            function to apply to each found object or {@code null}
   *                       to not modify the components.
   *
   * @return the future found page.
   */
Search for a page.
@param collectionName of the collections that contains the models.
@param query          to obtain the components of the page.
@param options        to apply to the search.
@param resultKey      to store the found models.
@param map            function to apply to each found object or  null
to not modify the components.

@return the future found page.
Search for a page . @param collectionName of the collections that contains the models . @param query to obtain the components of the page . @param options to apply to the search . @param resultKey to store the found models . @param map function to apply to each found object or null to not modify the components . @return the future found page .
protected Future<JsonObject> searchPageObject(final String collectionName, final JsonObject query,
      final FindOptions options, final String resultKey, final Consumer<JsonObject> map) {
    return this.pool.count(collectionName, query).compose(countResult -> {
      final var total = countResult.longValue();
      final var offset = options.getSkip();
      final var page = new JsonObject().put("offset", offset).put("total", total);
      if (total == 0 || offset >= total) {
        return Future.succeededFuture(page);
      } else {
        options.getFields().put(SCHEMA_VERSION, false);
        return this.pool.findWithOptions(collectionName, query, options).compose(foundObjects -> {
          if (map != null) {
            foundObjects.stream().forEach(map);
          }
          page.put(resultKey, foundObjects);
          return Future.succeededFuture(page);
        });
      }
    });
  }
protected Future < JsonObject > searchPageObject ( final String collectionName , final JsonObject query , final FindOptions options , final String resultKey , final Consumer < JsonObject > map ) { return this . pool . count ( collectionName , query ) . compose ( countResult -> { final var total = countResult . longValue ( ) ; final var offset = options . getSkip ( ) ; final var page = new JsonObject ( ) . put ( "offset" , offset ) . put ( "total" , total ) ; if ( total == 0 || offset >= total ) { return Future . succeededFuture ( page ) ; } else { options . getFields ( ) . put ( SCHEMA_VERSION , false ) ; return this . pool . findWithOptions ( collectionName , query , options ) . compose ( foundObjects -> { if ( map != null ) { foundObjects . stream ( ) . forEach ( map ) ; } page . put ( resultKey , foundObjects ) ; return Future . succeededFuture ( page ) ; } ) ; } } ) ; }
Search for a page.
Search for a page .