2017-05-10 3 views
0

에 의해 등록되지 않은,이 같은이요청이 내 웹 사이트에서 응용 프로그램

을 - 위한 인증과 초기화 :

forecastValue.authentification() 
    .then(function(report) { 
     $scope.currentName = report[0].informationUser.id_name; 
      forecastValue.getAdmins($scope.currentName) 
      .then(function(reports) { 
       $scope.listAdmins = reports[0].listAdmins; 
       console.log(reports[0].listAdmins); 
       }).catch(function(err) { 
        $scope.listAdmins= []; 
        console.error('Unable to fetch forecast report: ' + err); 
        }); 

     }).catch(function(err) { 
      $scope.currentName= ''; 
      console.error('Unable to fetch forecast report: ' + err); 
      }); 

년 - 기능, 관리자를 삭제, 그것은 후 게시 요청에 공장 부분에 전달된다.

$scope.deleteAdmin = function() { 


     forecastValue.deleteAdmin($scope.adminselected) 
     .then(function(report){ 
      console.log("Changes saved"); 
      $scope.adminmessage = "L'utilisateur "+ $scope.adminselected+" n'est plus administrateur"; 
     }).catch(function(err){ 
     console.error("Changes not saved"); 
     }); 

     forecastValue.getAdmins($scope.currentName) 
      .then(function(reports) { 
       $scope.listAdmins = reports[0].listAdmins; 
       }).catch(function(err) { 
        $scope.listAdmins= []; 
        console.error('Unable to fetch forecast report: ' + err); 
     }); 

}}; Node.js를 코드 실행

그리고 MySQL의 요청

는 다음 중 하나입니다 : 데이터베이스에

-I 검사, 소프트웨어와 함께 : 그래서

function deleteAdmin(res, queryParams) 
{ 

    connection.query("DELETE FROM safeplusdb.admin WHERE name=\""+(decodeURIComponent(queryParams.admindeleted))+"\";"); 


    res.send({ 
    state: "OK" 
    }); 
} 

, 결과는 다음과 같다 Workbench에서 데이터가 h 제됩니다.

- F5 또는 Ctrl + F5를 눌러도 웹 사이트에 아무것도 등록되지 않고 데이터가 그대로 유지됩니다. 변경 사항을 적용하는 유일한 방법은 응용 프로그램을 중지하고 "node server.js"명령을 사용하여 응용 프로그램을 다시 시작하는 것입니다.

SQL 업데이트 방법을 사용할 때 이와 같은 문제가 없었습니다.

어떻게 설명하나요?

답변

0

솔루션 :

function deleteAdmin(res, queryParams) 
{ 

    connection.query("DELETE FROM safeplusdb.admin WHERE name=\""+(decodeURIComponent(queryParams.admindeleted))+"\";", function(err, records){ 
     if(err) throw err; 

     connection.query("SELECT * FROM safeplusdb.admin;", function (err, records){ 
      if(err) throw err; 

      adminlist=[]; 
      for(i=0; i<records.length; i++) 
      { 
      adminlist[i]=records[i].name; 
      } 

      res.send({ 
      state: "OK" 
      }); 
     }); 
    }); 

} 

아이디어는 웹 브라우저, immediatly, 모든 datas를 갱신하기 위해, DELETE 요청에 삽입 된베이스에 SELECT 요청을 만드는 것입니다. 그것은 작동합니다!