-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathclear_database.js
25 lines (20 loc) · 958 Bytes
/
clear_database.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
function clear_collection(colname) {
print('Working on collection ' + colname);
print('* Before:');
size = db[colname].totalSize()
reccount = db[colname].count()
print('* Total for ' + colname + ' in bytes: ' + size);
print('* Total for ' + colname + ' in record count: ' + reccount);
db[colname].deleteMany({});
print('* After:');
size = db[colname].totalSize()
reccount = db[colname].count()
print('* Total for ' + colname + ' in bytes: ' + size);
print('* Total for ' + colname + ' in record count: ' + reccount);
print('');
}
var db = connect('mongodb:27017/mnemosyne');
var collections = ["counts", "daily_stats", "dork", "file", "hpfeed", "metadata", "session", "url"];
print('* Be patient while records delete, in large databases this call may take several minutes');
collections.forEach(clear_collection);
print('It may take some time for the deletions to reflect in the size...be patient!');