File tree Expand file tree Collapse file tree 3 files changed +18
-11
lines changed Expand file tree Collapse file tree 3 files changed +18
-11
lines changed Original file line number Diff line number Diff line change 1
1
2
2
3
3
4
- const { actionModel } = require ( '../models/action .model' )
4
+ const { incidencesModel } = require ( '../models/incidences .model' )
5
5
6
6
exports . createAction = ( req , res ) => {
7
- actionModel
7
+ incidencesModel
8
8
. create ( {
9
9
done : req . body . done ,
10
10
status : req . body . done ,
11
11
startDate : req . body . startDate ,
12
- finishDate : req . body . finishDate ,
13
12
finishDate : req . body . finishDate
14
13
} )
15
14
. then ( user => {
16
-
15
+ res . status ( 200 ) . json
17
16
} )
18
17
. catch ( err => {
19
18
console . log ( err )
20
- res . status ( 500 ) . json ( { msg : 'Error ' } )
19
+ res . status ( 500 ) . json ( { msg : 'Error ' } )
21
20
} )
22
21
}
23
22
24
23
25
24
26
25
exports . updateAction = ( req , res ) => {
27
- actionModel
28
- . findOneAndUpdate ( { } )
29
- }
26
+ incidencesModel
27
+ . findById ( req . params . incidenceId )
28
+ . then ( incidence => {
29
+ incidence . actions . filter ( )
30
+ } )
31
+ }
32
+
33
+ exports . getAction = ( req , res ) => {
34
+ incidencesModel
35
+ . find ( )
36
+ }
Original file line number Diff line number Diff line change @@ -35,7 +35,7 @@ const incidenceSchema = new mongoose.Schema({
35
35
required : true
36
36
} ,
37
37
incidencesCategory : [ incidenceCategoriesSchema ] ,
38
- actions : [ actionSchema ] ,
38
+ actions : [ [ actionSchema ] ] ,
39
39
client : [ clientSchema ]
40
40
} )
41
41
Original file line number Diff line number Diff line change 6
6
getAction
7
7
} = require ( '../controllers/action.controllers' )
8
8
9
- actionRouter . get ( '/incidences/getAction' , getAction )
9
+ actionRouter . get ( '/incidences/:incidenceId/:actionId/ getAction' , getAction )
10
10
actionRouter . post ( '/incidences/createAction' , createAction )
11
- actionRouter . put ( '/incidences/updateAction' , updateAction )
11
+ actionRouter . put ( '/incidences/:incidenceId/:actionId/ updateAction' , updateAction )
12
12
13
13
exports . actionRouter = actionRouter
You can’t perform that action at this time.
0 commit comments