【问题标题】:Azure Mobile Services Table Object InitializationAzure 移动服务表对象初始化
【发布时间】:2013-06-17 18:30:47
【问题描述】:

我正在开发 azure 移动服务脚本。在一个表的插入脚本代码中,我想在另一个表中插入一条记录。我知道可以使用 table.insert() 函数,但我没有找到在脚本中初始化表对象的方法。该脚本无法将表名称识别为可以初始化的类型。可能是我错过了一些基本点。以下代码可能有助于您理解:

function insert(item, user, request) {   
Misc misc = new Misc();   // 'Misc' is the table name and it is not recognized as a type.
misc.name = "John";
var tblMisc = tables.getTable('Misc');
tblMisc.insert(misc);
...}

【问题讨论】:

    标签: azure-mobile-services


    【解决方案1】:

    Azure 移动服务脚本语言是动态类型的 Node.js,因此 Misc misc = new Misc(); 不起作用。

    您可以将第一行更改为:

    var misc = {};

    或者只是将所有内容替换为:

    tables.getTable('Misc').insert({ name: "John" });

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-07-18
      • 2013-06-27
      • 1970-01-01
      • 2011-01-02
      相关资源
      最近更新 更多