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 帖子上找到了答案,典型的......我做错的事情是没有提供要更新的列的名称。所以而不是:

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 回答