I'm developing a react-native app with react-native-firebase, and I'm trying to implement a transaction. here's my code:
const roomRef = firebase.database().ref('rooms').child(roomKey)
return roomRef.transaction(function(room) {
console.log('TRANSACTION STARTED')
if (room && !room.joiner) {
room.joiner = userId
}
return room
}, function(error, committed, snap) {
if (error) console.log(error)
if (committed) console.log('COMMITTED')
console.log(snap.val())
})
The problem is that this transaction function seems to be not executed. I'm sure that previous code run, but no updates in database appear, no console.log, nothing. Anybody can help me please?
EDIT
I noticed that no transaction works in my app, whatever the conditions are. In cloud functions I'm using the admin SDK, and in this case transactions work.