-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcurrent_exercises_controller.js
60 lines (50 loc) · 2.6 KB
/
current_exercises_controller.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
module.exports = {
create: ( req, res, next ) => {
const dbInstance = req.app.get('db');
console.log("Vincent is accessing the create method in current_controller.js")
const { frontsquat, backsquat, pendlayrow, deadlift, shoulderpress, inclinebench, benchpress, bicepcurl, tricepcurl, deadliftreps, pendlayrowreps, backsquatreps, frontsquatreps, benchpressreps, inclinebenchreps, shoulderpressreps, bicepcurlreps, tricepcurlreps } = req.body;
console.log(frontsquat, backsquat, pendlayrow, deadlift, shoulderpress, inclinebench, benchpress, bicepcurl, tricepcurl, deadliftreps, pendlayrowreps, backsquatreps, frontsquatreps, benchpressreps, inclinebenchreps, shoulderpressreps, bicepcurlreps, tricepcurlreps )
console.log("USER BEFORE CREATE EXERCISE",req.user);
dbInstance.create_exercises([ frontsquat, backsquat, pendlayrow, deadlift, shoulderpress, inclinebench, benchpress, bicepcurl, tricepcurl, req.user[0].authid, deadliftreps, pendlayrowreps, backsquatreps, frontsquatreps, benchpressreps, inclinebenchreps, shoulderpressreps, bicepcurlreps, tricepcurlreps ])
.then( (response) => res.status(200).send(response) )
.catch( (err) => res.status(500).send(err) );
},
getOne: ( req, res, next ) => {
const dbInstance = req.app.get('db');
const { params } = req;
console.log('getting one ', params);
dbInstance.read_exercise([ userid ])
.then( response => res.status(200).send( response ) )
.catch( () => res.status(500).send() );
},
getLast: ( req, res, next ) => {
const dbInstance = req.app.get('db');
console.log("getting lastData")
console.log(req.user[0].authid)
dbInstance.read_exercise(req.user[0].authid)
.then( response => res.status(200).send( response ) )
.catch( () => res.status(500).send(req.body) );
},
getAll: ( req, res, next ) => {
const dbInstance = req.app.get('db');
console.log("getting lastfive")
console.log(req.user[0]);
dbInstance.read_exercises(req.user[0].authid)
.then( response => res.status(200).send( response ) )
.catch( () => res.status(500).send(req.body) );
},
update: ( req, res, next ) => {
const dbInstance = req.app.get('db');
const { params, query } = req;
dbInstance.update_exercises([ params.id, query.desc ])
.then( () => res.status(200).send() )
.catch( () => res.status(500).send() );
},
delete: ( req, res, next ) => {
const dbInstance = req.app.get('db');
const { params } = req;
dbInstance.delete_exercise([ params.id ])
.then( () => res.status(200).send() )
.catch( () => res.status(500).send() );
}
};