0 votes
in MongoDB by
Delete everything in a MongoDB database

1 Answer

0 votes
by
I’m doing development on MongoDB. For totally non-evil purposes, I sometimes want to blow away everything in a databasethat is, to delete every single collection, and whatever else might be lying around, and start from scratch. Is there a single line of code that will let me do this in MongoDB? Bonus points for giving both a MongoDB console method and a MongoDB Ruby driver method.

1

2

3

4

5

6

7

8

9

10

use [database];

db.dropDatabase();

Ruby code should be pretty similar.

Also, from the command line:

mongo [database] –eval “db.dropDatabase();”Use

[databaseName]

db.Drop+databaseName();

drop collection

use databaseName

db.collectionName.drop();

Related questions

+1 vote
asked Aug 24, 2020 in MongoDB by Hodge
+1 vote
0 votes
asked Nov 1, 2020 in MongoDB by SakshiSharma
...