Thank you the link, I forgot about that possibility, but it's not enough.
When I use that, if I want to transform my instance into JSON, my object contains CODE_IBAN and not codeIBAN.
describe('sequelize', function(){
var Sequelize = require('sequelize'),
sequelize = new Sequelize('test', 'user', null, { dialect: 'sqlite' }),
Account = sequelize.define('ACCOUNT', {
CODE_IBAN: Sequelize.INTEGER
}, {
getterMethods: {
codeIBAN: function() {
return this.getDataValue('CODE_IBAN');
}
},
setterMethods: {
codeIBAN: function(value) {
return this.setDataValue('CODE_IBAN', value);
}
}
});
it('test database column mapping', function(done){
sequelize.sync().success(function() {
Account.build({
codeIBAN: 1
}).save().success(function(account){
expect(account.codeIBAN).
to.be(1);
expect(account.values.codeIBAN).to.be(1); done();
}).error(function(err){
done(err);
});
}).error(function(err){
done(err);
});
});
});
I used different ORM in C#, Java and scala where you can map the property of your model on any column name. I'm surprised we can't do that here. Maybe, I missing something.