-1


Is there a single method from MongoDB Java driver which deletes all documents in a collection ? so far I've only been able to do this by browsing a cursor and calling delete on each Document. Thanks

Marc
  • 3,683
  • 8
  • 34
  • 48
user2824073
  • 2,407
  • 10
  • 39
  • 73

1 Answers1

2

You can use :

MongoClient mongoClient = new MongoClient();
DB db = mongoClient.getDB("dbName");
DBCollection myCollection = db.getCollection("collectionName");
myCollection.drop();
Vishwas
  • 6,967
  • 5
  • 42
  • 69