I'm looking to do an upsert with a firestore document like:
gameDb
.collection("player-scores")
.doc(playerId)
.update({ score: firebase.firestore.FieldValue.increment(1) });
If playerId document exists, then update the score, otherwise set it to 1.
If I do
gameDb
.collection("player-scores")
.doc(playerId)
.set({ score: firebase.firestore.FieldValue.increment(1) });
it works as I want for a moment and score is set to either 1 or the incremented value, but then the incremented score is overwritten by 1