【发布时间】:2015-11-24 18:42:58
【问题描述】:
我是 SailsJs 的新手。我有一个 MySQL 数据库,其中包含 123 个表,其中包含很多字段。现在我想在我的 Sails 应用程序中使用该数据库。当我需要从任何表中获取数据时,我需要在模型中声明字段名称、类型等,如下所示
module.exports = {
tableName: 'Mytable',
adapter: 'someMysqlServer',
migrate: 'safe',
autoCreatedAt: false,
autoUpdatedAt: false,
attributes: {
id: {
type: 'number',
required:true
},
name: {
type: 'string',
required: true
}
}
};
现在我不想声明模型中的所有字段,因为我有这么多的表/字段。那么没有这个我怎么能选择/插入/更新数据。
【问题讨论】: