module.exports = (sequelize, DataTypes) => {
const userHeader = sequelize.define("userHeader",{
id: {
type: DataTypes.UUID,
allowNull: false,
unique: true,
primaryKey: true,
autoIncrement: true,
defaultValue : sequelize.literal('uuid_generate_v4()'),
},
userId: {
type: DataTypes.STRING(),
field : 'userid'
},
password: {
type: DataTypes.STRING(),
allowNull: false,
field : 'password'
},
userName: {
type: DataTypes.STRING(),
allowNull: true,
field : 'username'
},
usedCode: {
type: DataTypes.INTEGER,
allowNull: false,
field : 'usedcode'
},
companyId: {
type: DataTypes.UUID,
allowNull: false,
field : 'companyid'
},
createDate: {
type: DataTypes.DATE(3),
allowNull: false,
defaultValue: sequelize.literal("CURRENT_TIMESTAMP(3)"),
field : 'createdate'
}
userHeader.associate = function(models) {
// associations
userHeader.belongsTo(models.companyHeader,{
foreignKey: 'companyId',
targetKey : 'id',
// as : 'company'
})
};
return userHeader;
};