【问题标题】:Windows Azure Mobile Services multiple inserts, how to get the scope identityWindows Azure Mobile Services 多次插入,如何获取范围标识
【发布时间】:2013-05-15 22:50:21
【问题描述】:

在使用 Windows Azure 移动服务的其中一个表的插入脚本中,我想获取刚刚插入的 id 并将其用于在另一个表中插入子相关数据(一对多样式)

有什么想法吗?? 提前致谢

【问题讨论】:

    标签: windows azure


    【解决方案1】:

    请注意,您还可以获取在服务器脚本中插入的项目的 ID:

        var theNewRow = {
            youProperty1: 'inserted',
            yourProperty2: 'in server script'
        };
    
        yourTable.insert(theNewRow, {
            success: function()
            {
                console.log('the row id' + theNewRow.id);
            } 
        });
    

    【讨论】:

      【解决方案2】:
      function insert(item, user, request) {
      request.execute({
          success: function() {
              var id = item.id;
              console.log("The new item's id is: ", id);
              request.respond();
          }
      });
      

      }

      【讨论】:

      • 这在插入自定义 SQL 时特别有用。
      【解决方案3】:

      Carlos 在这篇文章中介绍了如何处理 1:n 关系:http://blogs.msdn.com/b/carlosfigueira/archive/2012/09/11/supporting-complex-types-in-azure-mobile-services-clients-implementing-1-n-table-relationships.aspx

      顺便说一句,您可以在此处找到一系列与移动服务相关的帖子:aka.ms/CommonWAMS

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2019-03-19
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多