I am using Firebase Firestore
to make my website
As you can see, I have a field commentList
and its type is array
and now I want to remove the first item of the array which contains a property comment: the first comment
This is what I did:
exports.delete__comment = (req, res, next) => {
const {id} = req.params;
const {comment} = req.body;
return db
.collection('instagram__posts')
.doc(id)
.update({
commentList: FieldValue.arrayRemove(JSON.stringify(comment)),
})
.then((doc) => {
console.log('comment deleted', comment);
next();
})
.catch((err) => {
res.status(500).json({err});
console.log(err);
});
};
if the item was deleted, I will console.log('comment deleted', comment);
and it worked
but the sad thing is it does not remove in the database for me instead, it still there. Please show me how to fix it, thank you so much and Merry Chirstmas
Aucun commentaire:
Enregistrer un commentaire