help with idAttribute
duard opened this issue · comments
Carlos Eduardo commented
How can I set diferent idAttribute to my table ?
something like this.idAttribute: 'cpf';
Saugat Acharya commented
Setting a different idAttribute is generally a bad idea. You can simply create another column which contains unique values and leave the idAttribute
as it is.
Something like this should work but it might have it's consequences.
class User extends bookshelf.Model {
get tableName() {
return TABLE_NAME;
}
get idAttribute() {
return 'cpf';
}
}
Carlos Eduardo commented
I try this yesterday and not work for me
Do you sugest I mantain the column id and set unique to CPF ?
get idAttribute() {
return 'cpf';
}
Saugat Acharya commented
Yes that is the way to do it.