Allow for a raw Mongo collection to be passed to Mongo repos

This commit is contained in:
Braydon 2023-12-17 02:16:02 -05:00
parent e8f3b45c68
commit 2ec91e3dcf

@ -37,8 +37,12 @@ public class MongoRepository<ID, E> extends Repository<MongoDB, ID, E> {
@NonNull private final MongoCollection<Document> collection; @NonNull private final MongoCollection<Document> collection;
public MongoRepository(@NonNull MongoDB database, @NonNull Class<? extends E> entityClass, @NonNull String collectionName) { public MongoRepository(@NonNull MongoDB database, @NonNull Class<? extends E> entityClass, @NonNull String collectionName) {
this(database, entityClass, database.getDatabase().getCollection(collectionName));
}
public MongoRepository(@NonNull MongoDB database, @NonNull Class<? extends E> entityClass, @NonNull MongoCollection<Document> collection) {
super(database, entityClass); super(database, entityClass);
collection = database.getDatabase().getCollection(collectionName); // Get the collection by the name this.collection = collection;
} }
/** /**