UNPKG

spark-property-manager

Version:
39 lines (36 loc) 1.34 kB
'use strict'; module.exports = (sequelize, DataTypes) => { var User = sequelize.define('User', { email: { type: DataTypes.STRING, allowNull: false, unique: true }, password: { type: DataTypes.STRING, allowNull: false }, firstname: DataTypes.STRING, lastname: DataTypes.STRING, phone: DataTypes.STRING, is_admin: { type: DataTypes.BOOLEAN, defaultValue: false }, is_manager: { type: DataTypes.BOOLEAN, defaultValue: false }, company_id: { type: DataTypes.INTEGER, references: 'company', // <<< Note, its table's name, not object name referencesKey: 'id' // <<< Note, its a column name } }, { // don't add the timestamp attributes (updatedAt, createdAt) timestamps: false, // don't use camelcase for automatically added attributes but underscore style // so updatedAt will be updated_at underscored: true, // disable the modification of tablenames; By default, sequelize will automatically // transform all passed model names (first parameter of define) into plural. // if you don't want that, set the following freezeTableName: true, tableName: 'login_user' }); User.associate = function (models) { models.User.belongsTo(models.Company, { onDelete: 'CASCADE', foreignKey: 'company_id' }); }; return User; };