fcsc_ipi_backend/app/models/cityTown.model.js

21 lines
711 B
JavaScript

module.exports = (sequelize, DataTypes) => {
const CityTown = sequelize.define('CityTown', {
id: { type: DataTypes.INTEGER, autoIncrement: true, primaryKey: true },
emirate_id: { type: DataTypes.INTEGER, allowNull: true },
name: { type: DataTypes.STRING, allowNull: false },
code: { type: DataTypes.STRING },
is_active: { type: DataTypes.BOOLEAN, defaultValue: true },
created_at: DataTypes.DATE,
updated_at: DataTypes.DATE,
}, {
tableName: 'city_towns',
timestamps: false,
});
CityTown.associate = (models) => {
CityTown.belongsTo(models.Emirate, { foreignKey: 'emirate_id', as: 'emirate' });
};
return CityTown;
};