Skip to content

Commit

Permalink
updated students route
Browse files Browse the repository at this point in the history
  • Loading branch information
Tonzi254 committed Feb 6, 2023
1 parent 692051d commit 1082e04
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 7 deletions.
4 changes: 0 additions & 4 deletions models/model.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,6 @@ const studentsSchema = new mongoose.Schema({
type: String,
default: "DevOps",
},
__v: {
versionKey: false
},

});

module.exports = mongoose.model('students', studentsSchema)
6 changes: 3 additions & 3 deletions routes/students.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ router.patch('/:id', async (req, res) => {
const id = req.params.id;
const updatedData = req.body;

console.log(id)
console.log(updatedData)
console.log(id);
console.log(updatedData);

const data = await student.findByIdAndUpdate(id, updatedData, { new: true });
res.status(200).json(data);
Expand All @@ -53,7 +53,7 @@ router.delete('/:id', async (req, res) => {
const id = req.params.id;

const data = await student.findByIdAndDelete(id);
res.status(200).json({message: `The student named ${data.first_name} ${data.last_name} has been deleted`});
res.status(204).json({message: `The student named ${data.first_name} ${data.last_name} has been deleted`});
} catch (error) {
res.status(400).json({ message: error.message });
}
Expand Down

0 comments on commit 1082e04

Please sign in to comment.