Class MongoClientWrapper

  • All Implemented Interfaces:
    Closeable, AutoCloseable

    @Beta
    public class MongoClientWrapper
    extends Object
    implements Closeable
    A wrapper around a MongoClient that also provides MongoDatabase and DB instances for a specific database, which is specified in the constructor.
    • Constructor Detail

      • MongoClientWrapper

        public MongoClientWrapper​(String mongoUri,
                                  String databaseName)
        Create a new instance with the given Mongo connection URI. Uses databaseName to get both MongoDatabase and DB instances, which are available from this instance via their getter methods.
        Parameters:
        mongoUri - the Mongo connection URI
        databaseName - the database associated with this instance
    • Method Detail

      • getDB

        public com.mongodb.DB getDB()
        Return the (deprecated) DB instance for clients that have not yet migrated to MongoDatabase.
        Returns:
        the DB instance associated with this instance (as specified in the constructor)