代码可以在Firebase后端自动运行吗?

时间:2017-11-10 15:29:29

标签: javascript angularjs firebase web-applications firebase-realtime-database

以下是我在Angular JS网站上的特定页面上运行的代码:

    databaseService.users.child(user.uid).on('value', function(usersSnapshot){
    var users = usersSnapshot.val();
    var total = users.total;

     var week1 = users.week1;
    var week2 = users.week2;
    var week3 = users.week3;
    var week4 = users.week4;
    var week5 = users.week5;
    var week6 = users.week6;
    var week7 = users.week7;
    var week8 = users.week8;
    var week9 = users.week9;
    var week10 = users.week10;
    var week11 = users.week11;
    var week12 = users.week12;

    var addition = week1 + week2 + week3 + week4 + week5 + week6 + week7 + week8 + week9 + week10 + week11 + week12;

    var seasonTotal = firebase.database().ref("users").child(user.uid).child("total");

  seasonTotal.set(addition);

我的问题是代码仅在用户登录时运行并转到运行代码的视图。但我希望为每个用户运行该添加,无论是否登录。这可能与firebase有关吗?也许云功能?

0 个答案:

没有答案