I am using delete function in a scenario for cache deleting data from mongodb but
how can i delete data which is specific object from redis. I used Lrem() but it didn't work, I would appreciate it if you could help me.
const deleteComment = async (req, res) => {
let key = `Comments/${req.query.postId}`;
try {
const deleteValue = await Comment.findOneAndDelete({
_id: req.params.id,
$or: [{ writer: req.user.id }, { authorId: req.user.id }],
})
.populate("responseTo", "writer")
.populate("postId", "authorId")
.populate("writer");
const jsonData = JSON.stringify(deleteValue);
await client.lRem(key, 0, jsonData);
res
.status(200)
.json({ success: true, message: "Comment Deleted", ıtem: deleteValue });
} catch (err) {
res.status(500).json({ message: err });
}
};