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 @@ -431,10 +431,9 @@ firebase.transaction(path, (currentValue => {
431431 if (currentValue === null ) {
432432 return 0 ;
433433 } else {
434- // console.log('User ada already exists.');
435- return ++ currentValue ; // Abort the transaction.
434+ return ++ currentValue ; // Increment the current value. Do not try to increment currentValue if its NaN!
436435 }
437- })) // firebase.Datasnapshot follows the web datasnapshot interface
436+ }))
438437 .then ((result : { committed: boolean , snapshot: firebase .DataSnapshot }) => {
439438 console .log (result .committed + " snapshotValue: " + result .snapshot .val ());
440439 }).catch (err => console .log (" Encountered an error " + err ));
@@ -460,7 +459,7 @@ firebaseWebApi.database().ref(path).transaction(currentValue => {
460459
461460firebaseWebApi .database ().ref (path ).transaction (currentValue => {
462461 if (currentValue === null ) {
463- return null ; // Do nothing if this value doesn't exist
462+ return null ; // Do nothing if this value doesn't exist or return undefined (null works here because theres nothing at this path)
464463 // return 0 // If you want to put a 0 in if no value exist
465464 } else {
466465 return ++ currentValue ; // increment the value
You can’t perform that action at this time.
0 commit comments