I'm trying to increment a counter value in my Firebase database using transactions. it works the first time, i.e. when the value is set to 1, but on updates after that, the value isn't updating.
Here's how my code:
firebaseRef.child("search_hashtags").child(hashtag).transaction(function(currentValue) {
return (currentValue || 0) + 1;
}, function(error, committed, ss) {
console.log(error);
console.log(committed);
console.log(ss);
});
The error I log says "[Error: set]"
I turned on Firebase logging and I'm getting this:
p:0: from server: {"r":3,"b":{"s":"ok","d":""}}
p:0: p response {"s":"ok","d":""}
p:0: handleServerMessage d {"p":"search_hashtags/test","d":1}
p:0: from server: {"r":4,"b":{"s":"ok","d":{}}}
p:0: listen response {"s":"ok","d":{}}
p:0: from server: {"r":5,"b":{"s":"datastale","d":"Transaction hash does not match"}}
p:0: p response {"s":"datastale","d":"Transaction hash does not match"}
0: transaction put response {"path":"/search_hashtags/test","status":"datastale"}
I'm doing similar transactions on other nodes in other parts of my code and they work fine, but for some reason this one fails...