MCPcopy Create free account
hub / github.com/codemistic/Web-Development / updatePost

Function updatePost

project_mern_memories/server/controllers/posts.js:44–55  ·  view source on GitHub ↗
(req, res)

Source from the content-addressed store, hash-verified

42}
43
44export const updatePost = async (req, res) => {
45 const { id } = req.params;
46 const { title, message, creator, selectedFile, tags } = req.body;
47
48 if (!mongoose.Types.ObjectId.isValid(id)) return res.status(404).send(`No post with id: ${id}`);
49
50 const updatedPost = { creator, title, message, tags, selectedFile, _id: id };
51
52 await PostMessage.findByIdAndUpdate(id, updatedPost, { new: true });
53
54 res.json(updatedPost);
55}
56
57export const deletePost = async (req, res) => {
58 const { id } = req.params;

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected