-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinitialize.js
133 lines (126 loc) · 3.94 KB
/
initialize.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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
const mongoose = require('mongoose'),
express = require('express'),
models = require('./server/models'),
winston = require('winston');
const app = express(),
dbUri = 'mongodb://localhost:27017/fitgDb',
AnaerobicExercise = models.AnaerobicExercise,
AerobicExercise = models.AerobicExercise;
const anaerobicExercises = [
{
name: "press banca",
category: "muscle training",
type: "chest",
custom: false,
description: "Press banca test description."
},
{
name: "pulley",
category: "muscle training",
type: "back",
custom: false,
description: "Pulley test description."
},
{
name: "shoulder press",
category: "muscle training",
type: "shoulder",
custom: false,
description: "Shoulder press test description."
},
{
name: "pulley triceps",
category: "muscle training",
type: "triceps",
custom: false,
description: "Pulley triceps test description."
},
{
name: "hammer",
category: "muscle training",
type: "biceps",
custom: false,
description: "Hammer test description."
},
{
name: "leg curl",
category: "muscle training",
type: "legs",
custom: false,
description: "Leg curl test description."
},
{
name: "gluteus machine",
category: "muscle training",
type: "gluteus",
custom: false,
description: "Gluteus machine test description."
},
{
name: "oblique abs",
category: "muscle training",
type: "abs",
custom: false,
description: "Oblique abs test description."
}
],
aerobicExercises = [
{
name: "trail running",
category: "running",
type: "trail running",
custom: false,
description: "Trail running test description."
},
{
name: "cross running",
category: "running",
type: "cross running",
custom: false,
description: "Cross running test description."
},
{
name: "sprint",
category: "running",
type: "sprint",
custom: false,
description: "Sprint test description."
},
{
name: "butterfly",
category: "swimming",
type: "butterfly",
custom: false,
description: "Butterfly test description."
},
{
name: "crawl",
category: "swimming",
type: "crawl",
custom: false,
description: "Crawl test description."
}
];
mongoose.connect(dbUri);
mongoose.connection.once('open', function () {
winston.info("MongoDB connection created in " + dbUri);
AnaerobicExercise.insertMany(anaerobicExercises)
.then(docs => {
winston.info('%d anaerobic exercises were successfully stored.', docs.length);
AerobicExercise.insertMany(aerobicExercises)
.then(docs => {
winston.info('%d anaerobic exercises were successfully stored.', docs.length);
mongoose.connection.close();
})
.catch(err => {
winston.info('An error has occurred during the aerobic exercises creation: ');
winston.info(err);
mongoose.connection.close();
});
})
.catch(err => {
winston.info('An error has occurred during the aerobic exercises creation: ');
winston.info(err);
mongoose.connection.close();
});
});