0

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()
                        {

                        }
    });
}

私が間違っていることや、使用する構文に関するヘルプがどこにあるかについて何か考えはありますか? ありがとう!

4

1 に答える 1

0

これまでに登場したことのない別の StackOverFlow Post で答え​​を見つけました。その代わりに:

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
}
于 2013-08-16T14:56:46.570 に答える