Is there a way to retrieve a value from a Firebase document and immediately update it?
I am familiar with methods for updating documents and retrieving their values separately, but how can I accomplish both in one go?
update
firebase.firestore().collection("colection").doc('document').set(
{
value: value + 10
}, { merge: true })
get
firebase.firestore().collection("colection").doc("document").get().then((doc) => {
if (doc.exists) {
console.log("Document data:", doc.data().value);
} else {
console.log("No such document!");
}
}).catch((error) => {
console.log("Error getting document:", error);
});