following the official documentation of firestore :
{
name: "Frank",
favorites: { food: "Pizza", color: "Blue", subject: "recess" },
age: 12
}
// To update favorite color:
db.collection("users").doc("frank").update({
"favorites.color": "Red"
})
I would like to use a dynamic key instead of color.
db.collection("users").doc("frank").update({
"favorites[" + KEY + "].color": true
});
this is of course not possible and will throw an error.
I've been trying to do this :
db.collection("users").doc("frank").update({
favorites: {
[key]: {
color": true
}
}
});
It is actually updating with the right key but unfortunately, it is overwriting the other keys (they are being deleted).