导出模块值

时间:2015-01-14 15:42:39

标签: node.js typescript sails.js waterline

我很困惑。我有以下javascript文件:

module.exports = {
  connection: 'freshairMysqlServer',
  tableName: 'Accounts',
  autoCreatedAt: false,
  autoUpdatedAt: false,
  autoPK: false,

  attributes: {
    idAccounts: {
      type: 'integer',
      primaryKey: true
    },
    AccountName: {
      type: 'string'
    },
    idOrganization: {
      type: 'integer'
    }
  },

  GetAccounts: function (page, cb) {
    Accounts.query('SELECT Accounts.AccountName as AccountName,' +
      ' Organizations.Name as Organization FROM Accounts' +
      ' JOIN Organizations on Accounts.idOrganization = Organizations.idOrganizations',
      function (err, results) {
        if (err) cb(err)
        else cb(null, results);
      });
  }
}

模块导出一个javascript对象,{connection:...,tableName:...,...}。 Sails使用此值来扩展Waterline模型对象。

完成相同操作的TypeScript代码是什么?我尝试了几种变化,但似乎没有得到它。救命!感谢。

1 个答案:

答案 0 :(得分:0)

var objectToExport = {
  connection: 'freshairMysqlServer', ... };
export = objectToExport;

并确保使用--module commonjs

进行编译