我尝试使用新版本1.0并重构我的项目。我有一个问题,我现在不知道如何解决她。我的BD上的一些表没有主键,当我迁移到sails 1.0时,我有这个错误
在模型
friends
中:主键设置为id
,但在模型上没有找到这样的属性。您必须在id
或api/Friends.js
中定义config/models.js
属性。有关信息,请参阅http://sailsjs.com/upgrading#?changes-to-model-configuration
我可以使用没有主键的模型吗?
我有同样的问题,我用来更改主键:在文件config / model.js
attributes: {
id: {
type: 'number',
autoIncrement: true,
},
}
and in the model api/any_model.js i used:
tableName : 'table',
attributes: {
id: {
type: 'number',
columnName : 'column_you_like_to_be_a_primaryKEY',
required : true
},
}
我找到了解决方案。我禁用了钩子orm,现在我很开心=)创建文件.sailsrc并写入
{“hooks”:{“orm”:false}}