r2
This commit is contained in:
@@ -0,0 +1,32 @@
|
||||
'use strict';
|
||||
|
||||
module.exports = (sequelize, DataTypes) => {
|
||||
const User = sequelize.define('User', {
|
||||
id: { type: DataTypes.INTEGER, primaryKey: true, autoIncrement: true },
|
||||
organizationId: { type: DataTypes.INTEGER },
|
||||
username: { type: DataTypes.STRING, allowNull: false, unique: true },
|
||||
email: { type: DataTypes.STRING, unique: true },
|
||||
password: { type: DataTypes.STRING, allowNull: false },
|
||||
role: { type: DataTypes.ENUM('SystemAdmin', 'Owner', 'Coach', 'Client'), allowNull: false, defaultValue: 'Coach' },
|
||||
firstName: { type: DataTypes.STRING },
|
||||
lastName: { type: DataTypes.STRING },
|
||||
isActive: { type: DataTypes.BOOLEAN, defaultValue: true },
|
||||
lastLoginAt: { type: DataTypes.DATE },
|
||||
passwordChangedAt: { type: DataTypes.DATE },
|
||||
}, {
|
||||
defaultScope: {
|
||||
attributes: { exclude: ['password', 'passwordChangedAt'] },
|
||||
},
|
||||
});
|
||||
|
||||
User.prototype.toPublic = function () {
|
||||
const { password, passwordChangedAt, ...rest } = this.toJSON();
|
||||
return rest;
|
||||
};
|
||||
|
||||
User.associate = (models) => {
|
||||
User.hasMany(models.DeviceToken, { foreignKey: 'userId' });
|
||||
};
|
||||
|
||||
return { User };
|
||||
};
|
||||
Reference in New Issue
Block a user