diff --git a/src/main/java/net/frozenorb/apiv3/utils/MongoUtils.java b/src/main/java/net/frozenorb/apiv3/utils/MongoUtils.java index ec6d72e..130ed28 100644 --- a/src/main/java/net/frozenorb/apiv3/utils/MongoUtils.java +++ b/src/main/java/net/frozenorb/apiv3/utils/MongoUtils.java @@ -17,10 +17,11 @@ import java.util.List; @UtilityClass public class MongoUtils { - private static final FindOptions limitOne = new FindOptions().setLimit(1); + private static final FindOptions limitOneOptions = new FindOptions().setLimit(1); + private static final FindOptions defaultOptions = new FindOptions(); public static void findOneAndTransform(String collection, JsonObject query, Function transformation, Handler> callback) { - APIv3.getMongoClient().findWithOptions(collection, query, limitOne, res -> { + APIv3.getMongoClient().findWithOptions(collection, query, limitOneOptions, res -> { if (res.succeeded()) { if (!res.result().isEmpty()) { JsonObject json = res.result().get(0); @@ -37,7 +38,11 @@ public class MongoUtils { } public static void findManyAndTransform(String collection, JsonObject query, Function transformation, Handler>> callback) { - APIv3.getMongoClient().find(collection, query, res -> { + findManyAndTransform(collection, query, defaultOptions, transformation, callback); + } + + public static void findManyAndTransform(String collection, JsonObject query, FindOptions options, Function transformation, Handler>> callback) { + APIv3.getMongoClient().findWithOptions(collection, query, options, res -> { if (res.succeeded()) { Collection servers = Collections2.transform(res.result(), transformation); callback.handle(Future.succeededFuture(ImmutableList.copyOf(servers)));