2013-08-16 51 views
0

我剛剛開始使用Windows Azure進行開發。到目前爲止很好,但我堅持一個非常基本的問題:如何從移動服務腳本插入到不同的表中的項目?我已經在Windows Azure上的博客中發現的代碼似乎並不像宣傳的工作:在Windows Azure中將項目插入不同表格的腳本

function insert(item, user, request) { 

    var currentTable = tables.getTable('current'); // table for this script 
    var otherTable = tables.getTable('other'); // another table within the same db 

    var test = "1234"; 
    request.execute(); // inserts the item in currentTable 

    // DOESN'T WORK: returns an Internal Server Error 
    otherTable.insert(test, { 
         success: function() 
         { 

         } 
    }); 
} 

什麼我做錯了任何想法或在那裏我能找到的語法一些幫助使用?謝謝!

回答

0

找到了另一個StackOverFlow發佈的答案,從來沒有出現過,典型的... 我做錯了的事情是沒有提供更新列的名稱。所以不是有:

var test = "1234"; 
// DOESN'T WORK because no column is declared 
otherTable.insert(test, { 
        success: function() 
        { 

        } 
}); 

我應該有:

var test = {code : "1234"}; 
// WORKS because the script knows in what column to store the data 
// (here the column is called "code") 
otherTable.insert(test, { 
        success: function() 
        { 

        } 
}); 

所以給整個右代碼:

function insert(item, user, request) { 

    var currentTable = tables.getTable('current'); // table for this script 
    var otherTable = tables.getTable('other'); // another table within the same db 

    var test = {code: "1234"}; 
    request.execute(); // inserts the item in currentTable 

    otherTable.insert(test, { 
        success: function() 
        { 

        } 
    }); // inserts test in the code column in otherTable 
} 
相關問題