Reputation: 556
I try to use new version 1.0 and refactoring my project. I have one problem and i don't now how i can solve her. Some tables on my BD don't have primary keys and when i migrate to sails 1.0, i have this error
In model
friends
: The primary key is set toid
, but no such attribute was found on the model. You must define anid
attribute inapi/Friends.js
or inconfig/models.js
. See http://sailsjs.com/upgrading#?changes-to-model-configuration for info
Can i use my model without primary keys?
Upvotes: 2
Views: 1440
Reputation: 26
i have the same problem i used to change the primarykey this: in file 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
},
}
Upvotes: 1