"use strict"; module.exports = function(sequelize, DataTypes) { //The id field is auto added and made primary key. return sequelize.define('Venue', { id: { type: DataTypes.INTEGER, primaryKey: true, allowNull: false, autoIncrement: true }, name: { type: DataTypes.STRING, allowNull: false }, createdAt: { type: DataTypes.DATE, allowNull: false }, updatedAt: { type: DataTypes.DATE, allowNull: false }, deletedAt: { type: DataTypes.DATE, allowNull: true } }, { freezeTableName: true, // Model tableName will be the same as the model name, paranoid: true, classMethods: { associate: function(models) { models.Venue.belongsTo(models.VenueType, {as: 'type', foreignKey: {name: 'typeId', field: 'typeId'}}); } } }); };