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

Function likePost

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

Source from the content-addressed store, hash-verified

65}
66
67export const likePost = async (req, res) => {
68 const { id } = req.params;
69
70 if (!mongoose.Types.ObjectId.isValid(id)) return res.status(404).send(`No post with id: ${id}`);
71
72 const post = await PostMessage.findById(id);
73
74 const updatedPost = await PostMessage.findByIdAndUpdate(id, { likeCount: post.likeCount + 1 }, { new: true });
75
76 res.json(updatedPost);
77}
78
79
80export default router;

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected