From 7a168bbb0530be0a79928a6e550b8db4493fdd94 Mon Sep 17 00:00:00 2001 From: Braydon Date: Sat, 16 Dec 2023 18:13:06 -0500 Subject: [PATCH] Allow a Mongo repo to have a collection name specified --- .../me/braydon/feather/database/impl/mongodb/MongoDB.java | 2 +- .../feather/database/impl/mongodb/MongoRepository.java | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/java/me/braydon/feather/database/impl/mongodb/MongoDB.java b/src/main/java/me/braydon/feather/database/impl/mongodb/MongoDB.java index ec449c3..0760021 100644 --- a/src/main/java/me/braydon/feather/database/impl/mongodb/MongoDB.java +++ b/src/main/java/me/braydon/feather/database/impl/mongodb/MongoDB.java @@ -124,7 +124,7 @@ public class MongoDB implements IDatabase { if (!isConnected()) { // Not connected throw new IllegalStateException("Not connected"); } - return new MongoRepository<>(this, entityClass, database.getCollection(collectionName)); + return new MongoRepository<>(this, entityClass, collectionName); } /** 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 2983ac7..c10fc81 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 @@ -36,9 +36,9 @@ public class MongoRepository extends Repository { */ @NonNull private final MongoCollection collection; - public MongoRepository(@NonNull MongoDB database, @NonNull Class entityClass, @NonNull MongoCollection collection) { + public MongoRepository(@NonNull MongoDB database, @NonNull Class entityClass, @NonNull String collectionName) { super(database, entityClass); - this.collection = collection; + collection = database.getDatabase().getCollection(collectionName); // Get the collection by the name } /**