Update语句上的语法错误

时间:2017-03-19 15:06:21

标签: c# database

此代码的正确代码是什么我尝试在所有表格和列上放置[]并删除''关于价值观。

here is my code

2 个答案:

答案 0 :(得分:2)

将0,1,2,3更改为{0},{1},{2},{3}。同样,评论建议在字符串周围添加引号。

答案 1 :(得分:2)

编写此查询的最佳方式如下

// Listen to every people in our query...
  geoQuery40.on("key_entered", function(key) {
    // ... and look them up by key ...
    restaurantsRef40.child(key).on("value", function(snapshot42) {
      var restaurant40 = snapshot42.val();
      var displayBusinessName = snapshot42.val().name;
      var displayBusinessDescription = snapshot42.val().description;
      var displayBusinessUid = snapshot42.val().uid;
      firebase.database().ref('accounts/' + userId + '/currentBusiness/').update({
        name: displayBusinessName,
        description: displayBusinessDescription,

        })
          //add the user in the Business' rotary

        var refRotary = firebase.database().ref('business/' + displayBusinessUid + '/rotary/' + userId);
        refRotary.once('value', function(snapshot78) {
          var displayVisit = snapshot78.val().lastVisit;
          var displayCurrentVisit = snapshot78.val().currentVisit;
          var displayWelcomeMessage = snapshot78.val().welcomeMessage;
          var displayBusinessPic = snapshot78.val().photoURL;
          $timeout(function() {
          $scope.displayVisit = displayVisit;
          $scope.displayCurrentVisit = displayCurrentVisit;
          $scope.displayWelcomeMessage = displayWelcomeMessage;
          $scope.displayBusinessPic = displayBusinessPic;

          if (displayCurrentVisit === undefined){
            firebase.database().ref('business/' + displayBusinessUid + '/rotary/' + userId).update({
              uid: userId,
              lastVisit: Date.now(),
              currentVisit: Date.now(),
            })
          } else {
        firebase.database().ref('business/' + displayBusinessUid + '/rotary/' + userId).update({
          uid: userId,
          lastVisit: displayCurrentVisit,
          currentVisit: Date.now(),
        })
}
          if (Date.now() - displayVisit > 3600000){
            firebase.database().ref('business/' + displayBusinessUid + '/rotary/' + userId + '/visits/').push({
              visit: Date.now(),
            })
          }

          var d = new Date();
          var g = new Date();
          d = d.toLocaleTimeString().replace(/:\d+ /, ' ');
          g = g.toLocaleTimeString().replace(/:\d+ /, ' ') + new Date();
          var refRotary2 = firebase.database().ref('business/' + displayBusinessUid);
          refRotary2.once('value', function(snapshot79) {
            var displayWelcomeMessage = snapshot79.val().welcomeMessage;
            var displayBusinessPic = snapshot79.val().photoURL;
            $timeout(function() {
              $scope.displayWelcomeMessage = displayWelcomeMessage;
            $scope.displayBusinessPic = displayBusinessPic;
          // envoie un message directement si c'est la premiere fois de la journee.
          var database = firebase.database();
          firebase.database().ref().child('/accounts/' + userId + '/discussions/' + userId + displayBusinessUid).set({
          blocked: 0,
          name: displayBusinessName,
          profilePic: displayBusinessPic,
          lastMessage: displayWelcomeMessage,
          time: d,
          discussionId: userId + displayBusinessUid,
          newMessages: 1,
          userId: displayBusinessUid,
          })
          firebase.database().ref().child('/messages/' + userId + displayBusinessUid).push({
          name: displayBusinessName,
          profilePic: displayBusinessPic,
          text: displayWelcomeMessage,
          time: d,
          userId: displayBusinessUid,
          })
          firebase.database().ref().child('/accounts/' + displayBusinessUid + '/discussions/' + userId + displayBusinessUid).set({
          name: displayBusinessName,
          profilePic: displayBusinessPic,
          lastMessage: displayWelcomeMessage,
          time: d,
          newMessages: 1,
          userId: displayBusinessUid,
          })
          // fin du message
        })
        })
        })

      })
        //end business rotary
    });
  });

其中con是连接字符串的对象。