app.put('/comment', function (req, res) {
console.log('editing id ${req.body._id}')
let toUpdate = { _id: req.body._id };
db.collection('post').updateOne(
toUpdate, { $push: { comment: req.body.comment } },
(err, results) => {
console.log(err)
console.log(results)
if (results.matchedCount === 0) {
res.send('no permission')
} else {
console.log('edited');
res.redirect('/list');
}
}
);
});
console.log(results ) //
{
acknowledged: true,
modifiedCount: 0,
upsertedId: null,
upsertedCount: 0,
matchedCount: 0
}
구글링을 해보니 $push 를 사용하면 된다고 해서 써봤는데 업데이트가 안되네요ㅜㅜ
어느부분이 잘못된 건지 알려주시면 감사하겠습니다