forked from sectoolstutorial/Wisclick
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathResetMongo.js
33 lines (27 loc) · 1018 Bytes
/
ResetMongo.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
26
27
28
29
30
31
32
/**
* Used for clearning up the database
*
* Wipe out the existing database collection LoginInformation
* Create a new one with five users with basic information
*
* @author Emma He
*/
// Connect to the mongoDB server
var connectMongo = new Mongo("localhost:27017");
var db = connectMongo.getDB("myDb");
// Delete the entire LoginInformation Collection if it exist
db.LoginInformation.drop();
// Create a new instance of LoginInformation Collection and insert initial info
db.createCollection("LoginInformation");
db.LoginInformation.insert([
{username: "victim", password: "thevictim", points: 6000.0},
{username: "Bucky", password: "badger", points: 5000.0},
{username: "Miku", password: "vocal", points: 4900.0},
{username: "Joe", password: "Doe", points: 4700.0},
{username: "attacker", password: "theattacker", points: 500.0}
]);
// print out the data to check if the insertion is correct
myCursor = db.LoginInformation.find();
while (myCursor.hasNext()){
printjson(myCursor.next());
}