I run a payment system with Stripe and am trying to decrement a quantity field in Firestore after every successful purchase. I can get the document but I'm struggling figuring out how to update it.
db.collection('products').where('id', '==', dbRef).get()
.then(querySnapshot => {
return querySnapshot.forEach(doc => {
return res.json({
data: doc.data(),
err: err
})
})
})
{
"data": {
"stripe": {
"sku": "sku_xxx",
"product": "prod_xxx"
},
"name": "VERSA HOODIE",
"id": "pmz0pvfa",
"createdBy": "Q3Vn0LLRnSWzxaeOK7V0UYbuiKF2",
"price": "25.00",
"quantity": 10,
"inStock": true,
"description": "TEST PRODUCT",
"imageURL": "https://xxx"
},
"err": null
}
I tried stuff like doc.update({})
, but it doens't work...
Thanks in advance