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

-The機能、管理者を削除し、それが後のPOSTリクエストの工場の一部で送信されます。

$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の要求は、次のいずれかになります。

function deleteAdmin(res, queryParams) 
{ 

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


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

ので、結果は以下の通りであるソフトウェアを使用して、データベース内

-Iチェック、ワークベンチでは、データが削除されます。

- F5キーまたはCtrl + F5キーを押しても、Webサイトには何も登録されていません。データはここに残ります。 変更を適用する唯一の方法は、アプリケーションを停止し、コマンド "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" 
      }); 
     }); 
    }); 

} 

アイデアは、Webブラウザのために、すぐに、すべての件のデータをリフレッシュするために、DELETE要求に挿入された基材上にSELECTリクエストを作ることです。できます !

関連する問題