-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathinitDatabase.js
34 lines (23 loc) · 1.02 KB
/
initDatabase.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
33
34
const MongoClient = require('mongodb').MongoClient;
// Connection URL
const url = 'mongodb://localhost:27017';
// Database Name
const dbName = 'MovIt';
// Use connect method to connect to the server
MongoClient.connect(url, function(err, client) {
if (err) {
console.error(`There was an error in the connect: ${err.message}`);
}
console.log("Connected successfully to server");
const db = client.db(dbName);
const configCollection = db.collection('Config');
configCollection.remove({});
configCollection.insert({"Value" : "Recommandation"});
configCollection.insert({"Value" : "Configuration"});
configCollection.insert({"Value" : "Goal"});
const configUser = db.collection('User');
configUser.remove({});
configUser.insert({"username" : "user", "password" : "948FE603F61DC036B5C596DC09FE3CE3F3D30DC90F024C85F3C82DB2CCAB679D"}); //client
configUser.insert({"username" : "clinician", "password" : "8c6976e5b5410415bde908bd4dee15dfb167a9c873fc4bb8a81f6f2ab448a918"}); //admin
client.close();
});