Search code examples
spring-data-mongodbmongodb-java

dropDatabase from spring mongo


I would like to dropDatabase in my mongo before my integration tests. Is it possible to do this through spring mongo ?

If it's not available for now, is it possible on fetching the com.mongodb.DB object somehow from spring mongo, so i can invoke it's dropDatabase() ?


Solution

  • A slightly cleaner solution which I am using is to use the MongoDbFactory object, as below:

    mongoDbFactory.getDb().dropDatabase();