Is it possible to have column names be underscored (postgres) but have the JavaScript getters be camelCase per language standards?
const People = sequelize. define('people', { name: DataTypes. STRING, }, { hooks: { beforeCount (options) { options. raw = true; } }, tableName: 'people', name: { singular: 'person', plural: 'people' } });
Without the underscored option, Sequelize would automatically define: A createdAt attribute for each model, pointing to a column named createdAt in each table. An updatedAt attribute for each model, pointing to a column named updatedAt in each table.
camelCase is used by JavaScript itself, by jQuery, and other JavaScript libraries.
For anyone finding this later on it's now possible to explicitely define what the database field should be named:
var User = sequelize.define('user', { isAdmin: { type: DataTypes.BOOLEAN, field: 'is_admin' } });
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With