0
votes

I am getting the following error when I try to upload a firebase functions

Error occurred while parsing your function triggers.

/private/var/folders/_5/96_hf2sx4dj69gzfm6bz9fl80000gn/T/fbfn_62815Dgk529e7Q94f/index.js:94 if (current_value - 1) >= 0 { ^^

SyntaxError: Unexpected token >=

the code is as follows

exports.countFollowing2 = functions.database.ref('/{pushId}/following/')
    .onDelete(event => {

      event.data.ref.parent.child('following_count').transaction(function (current_value) {

        if (current_value - 1) >= 0 {
          return (current_value - 1);
        }
        else{
          return 0;
        }

      });


    });

I'm assuming I'm doing something stupid and its a simple fix but I haven't been able to figure it out. Thanks for the help in advance!

1

1 Answers

0
votes

Replace if (current_value - 1) >= 0 { with if ((current_value-1) >= 0) {.

The important difference is that parenthesis must enclose the entire condition. This is different from Swift (if you come from that background), where having parenthesis around the condition itself are optional.