Skip to content
This repository was archived by the owner on Apr 4, 2023. It is now read-only.

Commit e1af4f6

Browse files
committed
[docs] - Update Transaction documentation
1 parent 2aa9a15 commit e1af4f6

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

docs/DATABASE.md

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -495,10 +495,9 @@ firebase.transaction(path, (currentValue => {
495495
if (currentValue === null) {
496496
return 0;
497497
} else {
498-
// console.log('User ada already exists.');
499-
return ++currentValue; // Abort the transaction.
498+
return ++currentValue; // Increment the current value. Do not try to increment currentValue if its NaN!
500499
}
501-
})) // firebase.Datasnapshot follows the web datasnapshot interface
500+
}))
502501
.then((result: { committed: boolean, snapshot: firebase.DataSnapshot }) => {
503502
console.log(result.committed + " snapshotValue: " + result.snapshot.val());
504503
}).catch(err => console.log("Encountered an error " + err));
@@ -524,7 +523,7 @@ firebaseWebApi.database().ref(path).transaction(currentValue => {
524523

525524
firebaseWebApi.database().ref(path).transaction(currentValue => {
526525
if (currentValue === null) {
527-
return null; // Do nothing if this value doesn't exist
526+
return null; // Do nothing if this value doesn't exist or return undefined (null works here because theres nothing at this path)
528527
//return 0 // If you want to put a 0 in if no value exist
529528
} else {
530529
return ++currentValue; // increment the value

0 commit comments

Comments
 (0)