0
を引っ張る使用してネストされた配列から項目を削除し、私が使用findOneAndUpdate
と$pull
をしたいと思います。私のポイントは、reply
配列から項目を削除することです。私は_id
によってコメントの項目を見つけようとしていますが、この返答項目を削除しますが、これは機能しません。以下の私のコードを見てください。
router.put('/dashboard/admin/komentarz/odpowiedz/usun/', function(req, res) {
var currentCourse = req.body._id; // main item id
var deleteReply = req.body.reply; // reply item id
var commentId = req.body.commentId // comments item id
Product.findOneAndUpdate({ _id: currentCourse }, { $pull: { reply: req.body.reply }}, function(err, product){
//some code
})