Creating New Child Added To The Array Field Creating New Child Added To The Array Field mongoose mongoose

Creating New Child Added To The Array Field


req.body.task is an array. So you have to access the post with req.body.task[0].post.

const updatedPost = await TodoModels.findByIdAndUpdate(id,{$push:{task:{post: req.body.task[0].post }}},{ new: true });