Skip to content

Commit 5a12e6d

Browse files
committed
first get req. created
1 parent 8784970 commit 5a12e6d

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

CRUD API's/app/controllers/controller.js

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff 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
2836
exports.findone=function(req,res){
37+
2938

3039
};
3140

CRUD API's/app/models/model.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff 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

0 commit comments

Comments
 (0)