From 2ec91e3dcf3e0e701833e5da0f71735e60875503 Mon Sep 17 00:00:00 2001 From: Braydon Date: Sun, 17 Dec 2023 02:16:02 -0500 Subject: [PATCH] Allow for a raw Mongo collection to be passed to Mongo repos --- .../feather/database/impl/mongodb/MongoRepository.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/main/java/me/braydon/feather/database/impl/mongodb/MongoRepository.java b/src/main/java/me/braydon/feather/database/impl/mongodb/MongoRepository.java index c1934ae..bd3dac2 100644 --- a/src/main/java/me/braydon/feather/database/impl/mongodb/MongoRepository.java +++ b/src/main/java/me/braydon/feather/database/impl/mongodb/MongoRepository.java @@ -37,8 +37,12 @@ public class MongoRepository extends Repository { @NonNull private final MongoCollection collection; public MongoRepository(@NonNull MongoDB database, @NonNull Class entityClass, @NonNull String collectionName) { + this(database, entityClass, database.getDatabase().getCollection(collectionName)); + } + + public MongoRepository(@NonNull MongoDB database, @NonNull Class entityClass, @NonNull MongoCollection collection) { super(database, entityClass); - collection = database.getDatabase().getCollection(collectionName); // Get the collection by the name + this.collection = collection; } /**