File tree Expand file tree Collapse file tree 2 files changed +12
-4
lines changed
Expand file tree Collapse file tree 2 files changed +12
-4
lines changed Original file line number Diff line number Diff line change @@ -15,17 +15,26 @@ exports.create=function(req,res){
1515 newnote . save ( )
1616 . then ( data => { res . status ( 200 ) . send ( data ) } )
1717 . catch ( err => {
18- res . status ( 400 ) . json ( { "message" : "error" } ) ;
18+ res . status ( 400 ) . json ( { "message" : "Some error occurred while creating the Note " } ) ;
1919 } ) ;
2020
2121 } ) ;
2222} ;
2323
24- exports . findAll = function ( req , res ) {
2524
25+ // to find all the notes
26+ exports . findAll = function ( req , res ) {
27+ Note . find ( )
28+ . then ( notes => {
29+ res . status ( 200 ) . send ( notes ) ;
30+ } ) . catch ( err => {
31+ res . status ( 400 ) . json ( { "message" : "Some error occurred while retrieving notes." } ) ;
32+ } ) ;
2633} ;
2734
35+ // find a note by id
2836exports . findone = function ( req , res ) {
37+
2938
3039} ;
3140
Original file line number Diff line number Diff line change @@ -14,8 +14,7 @@ const noteSchema=mongoose.Schema({
1414 type : String ,
1515 require : true
1616 }
17- } ,
18- {
17+ } , {
1918 timestamp : true
2019} ) ;
2120
You can’t perform that action at this time.
0 commit comments