我很困惑。我有以下 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 代码是什么?我尝试了几种变体,但似乎没有得到它。帮助!谢谢。
最佳答案
var objectToExport = {
connection: 'freshairMysqlServer', ... };
export = objectToExport;
并确保使用--module commonjs
进行编译
关于node.js - 导出模块值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27946836/