Firebase has documented how to handle transactions with Java but not with Nodejs(document)
Due to its structure transactions might return null at first run and unlike in Java, Nodejs doesn't have getValue(). What is returned from transaction is the value itself. So how can I apply the structure above to Nodejs?
In my code the data might be null and if that's the case it must set the count to 1. But when I'm getting "false nulls" I can't figure out what to do.
admin.database().ref(`/matches/${uid}/${matchUID}`)
.transaction(current => {
if (current === null) {
userMatchesRef.child(matchUID).set(1);
}
else {
userMatchesRef.child(matchUID).set(current + 1);
}
})