My Firestore database is structured like so:
I'm trying to update a "likes" field in the palettes
collection in a Firestore doc with an onClick
event and not having any luck.
I'm passing the name
field (in this case "Testing") to my onClick
handler to get the Firestore doc
ref and then trying to update that doc's 'likes' field value by 1.
Here is my onClick
handler:
const handleLike = name => {
// name is "Testing"
let palette = db.collection('palettes').doc(name)
palette.update({
likes: // what goes here??
})
}
How can I increment the likes
field value for the given palette doc?
Maybe this is not the way to go about it but if I have lots of palette docs, I'd like to avoid having to read in the entire collection to update it each time.