I want to delete all documents in a collection in java. Here is my code:
MongoClient client = new MongoClient(\"10.0.2.113\" , 27017); MongoDatabase
If you want to remove all documents in collection then used below code :
db.getCollection("mainCollection").remove(new BasicDBObject());
Or If you want to drop whole collection then used this :
db.getCollection("mainCollection").drop();