在使用 Windows Azure 移动服务的其中一个表的插入脚本中,我想获取刚刚插入的 id 并将其用于在另一个表中插入子相关数据(一对多样式)
任何的想法??提前致谢
function insert(item, user, request) {
request.execute({
success: function() {
var id = item.id;
console.log("The new item's id is: ", id);
request.respond();
}
});
}
请注意,您还可以获取在服务器脚本中插入的项目的 ID:
var theNewRow = {
youProperty1: 'inserted',
yourProperty2: 'in server script'
};
yourTable.insert(theNewRow, {
success: function()
{
console.log('the row id' + theNewRow.id);
}
});
Carlos 在这篇文章中介绍了使用 1:n 关系:http: //blogs.msdn.com/b/carlosfigueira/archive/2012/09/11/supporting-complex-types-in-azure-mobile-services-clients-实施-1-n-table-relationships.aspx
顺便说一句,您可以在此处找到一系列与移动服务相关的帖子:aka.ms/CommonWAMS