I have a simple transaction which should return the count of a child node stored in my realtime database and increment it. It might be worth noting this transaction is inside of a firebase cloud onWrite function.
The issue is that the data returned is null. I know this is possible when the client data is stale however the function exits without error and committed is false.
When I use the exact same reference to retrieve a data snapshot, the correct value is returned.
var ref = admin.database(devDB).ref('/path/to/countValue');
ref.transaction(function(count) {
if(count != null) {
var newCount = count + 1;
return newCount;
}
}, function(error, committed, ss) {
if(error) {
console.log('error: ', error);
}
console.log('committed: ', committed);
});