我在Windows Azure移动服务中工作。我有 2 张表计划 1:N 订阅(一个计划有多个订阅相关,一个订阅有一个计划相关)。我对JS服务器脚本不是很熟悉。当我插入一个新的下标时,我需要查询这个新订阅具有的计划(planId 来自订阅对象中的客户端)。所以我有这个:
function insert(item, user, request)
{
var planTable = tables.getTable("Plan");
//Here I want to select the plan from planTable using item.PlanId
request.execute();
}
你可以这样做(官方文档可在此处获得):
planTable.where({
id: item.PlanId
}).read({
success: function(results) {
// Do something here!
request.execute();
}
});
您可以在博客文章中找到确切的 http://blogs.msdn.com/b/carlosfigueira/archive/2012/09/11/supporting-complex-types-in-azure-mobile-services-clients-implementing-1-n-table-relationships.aspx 中解释的此方案。它包含扩展Sandrino Di Mattia答案的示例。