This repository was archived by the owner on Apr 4, 2023. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +3
-4
lines changed Expand file tree Collapse file tree 1 file changed +3
-4
lines changed Original file line number Diff line number Diff line change @@ -495,10 +495,9 @@ firebase.transaction(path, (currentValue => {
495
495
if (currentValue === null ) {
496
496
return 0 ;
497
497
} 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!
500
499
}
501
- })) // firebase.Datasnapshot follows the web datasnapshot interface
500
+ }))
502
501
.then ((result : { committed: boolean , snapshot: firebase .DataSnapshot }) => {
503
502
console .log (result .committed + " snapshotValue: " + result .snapshot .val ());
504
503
}).catch (err => console .log (" Encountered an error " + err ));
@@ -524,7 +523,7 @@ firebaseWebApi.database().ref(path).transaction(currentValue => {
524
523
525
524
firebaseWebApi .database ().ref (path ).transaction (currentValue => {
526
525
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)
528
527
// return 0 // If you want to put a 0 in if no value exist
529
528
} else {
530
529
return ++ currentValue ; // increment the value
You can’t perform that action at this time.
0 commit comments