Updated controller logic and reworked unit testing

This commit is contained in:
Gregory Campbell
2021-11-25 15:25:29 -05:00
parent 1933391ed3
commit 25cc71f485
7 changed files with 687 additions and 47 deletions
+2 -2
View File
@@ -22,7 +22,7 @@ const newMsg = (req, res) => {
//create a new msg object using the Msg model and req.params
const newMsg = new Msg({
id:req.params.id,
message:req.params.message,
message:req.body.message,
time: Date.now(),
})
@@ -65,7 +65,7 @@ const getOneMsg = (req, res) => {
const updateMsg = (req, res) => {
//check if the id already exists in db
Msg.findOneAndUpdate({id:req.params.id}, {message:req.params.message}, {new: true}, (err, data) => {
Msg.findOneAndUpdate({id:req.params.id}, {message:req.body.message}, {new: true}, (err, data) => {
//if this message is in db, update it
if (data) {