0

データベースに関連する問題があります。私は現在、Gupshup ボット プログラミングに取り組んでいます。ここここで読み取ることができる 2 つの異なるデータ永続化モードがあります。高度なデータ永続性では、データをデータベースに格納するために次のコードが文書化されています。

function MessageHandler(context, event) {
      if(event.message=='update bug - 1452') {
         jiraUpdate(context);
    }
          }
   function jiraUpdate(context){
       //connect to Jira and check for latest update and values
       if(true){
      context.simpledb.doPut("1452" ,"{\"status\":\"QA pending\",\"lastUpdated\":\"06\/05\/2016\",\"userName\":\"John\",\"comment\":\"Dependent on builds team to provide right build\"}");
} else{
         context.sendResponse('No new updates');
}
  }
function DbPutHandler(context, event) {
      context.sendResponse("New update in the bug, type in the bug id to see the update");
     } 

キー値が 1452 の行のテーブルの列 (ステータスまたは最終更新日など) の 1 つだけを変更したい場合、それを行うことはできません。どうすればそれができますか?

次のコードを使用しました。

function MessageHandler(context, event) {
    // var nlpToken = "xxxxxxxxxxxxxxxxxxxxxxx";//Your API.ai token
    // context.sendResponse(JSON.stringify(event));
if(event.message=='deposit') {
         context.sendResponse("Enter the amount to be deposited");
    }
    
     if(event.message=="1000") {
        jiraUpdate(context);
    }
    
    if(event.message== "show"){
context.simpledb.doGet("1452");
         
    }
}

function HttpResponseHandler(context, event) {
           var dateJson = JSON.parse(event.getresp);
           var date = dateJson.date;
           context.sendResponse("Today's date is : "+date+":-)");
       }
            
function jiraUpdate(context){
       //connect to Jira and check for latest update and values
       if(true){
      context.simpledb.doPut("aaa" ,"{\"account_number\":\"90400\",\"balance\":\"5800\"}");
} else{
         context.sendResponse('No new updates');
}

 }

/** Functions declared below are required **/
function EventHandler(context, event) {
    if (!context.simpledb.botleveldata.numinstance)
        context.simpledb.botleveldata.numinstance = 0;
    numinstances = parseInt(context.simpledb.botleveldata.numinstance) + 1;
    context.simpledb.botleveldata.numinstance = numinstances;
    context.sendResponse("Thanks for adding me. You are:" + numinstances);
}



function DbGetHandler(context, event) {
    var bugObj = JSON.parse(event.dbval);
             var bal = bugObj.balance;
  var acc = bugObj.account_number;
  context.sendResponse(bal);
  var a = parseInt (bal,10);
  var b = a +1000;
  var num = b.toString();
  context.simpledb.doPut.aaa.balance = num;
  
  
}

function DbPutHandler(context, event) {
    context.sendResponse("testdbput keyword was last put by:" + event.dbval);
}
4

1 に答える 1