Firebase功能中出现意外令牌

时间:2017-08-04 02:21:05

标签: firebase firebase-realtime-database google-cloud-functions

当我尝试上传firebase函数时,我收到以下错误

  

解析函数触发器时出错。

     

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

     

SyntaxError:意外的令牌> =

代码如下

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;
        }

      });


    });

我假设我做了一些愚蠢的事情并且这是一个简单的修复,但我无法弄明白。感谢您的帮助!

1 个答案:

答案 0 :(得分:0)

if (current_value - 1) >= 0 {替换为if ((current_value-1) >= 0) {

重要的区别是括号必须包含整个条件。这与Swift不同(如果你来自那个背景),其中条件本身的括号是可选的。

相关问题