/
Danik-Off
/
ProjectV
Обзор
Документация
Войти
/
Danik-Off
/
ProjectV
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
backend/models/user.js
75 строк
2 KB
Ovchinnikov Danila
feat: имя пользователя в голосом чате, роли, страница редактирования сервера, админка
07 июл 2025, 02:52
07 июл 2025, 02:52
c845acd
Код
Авторство
О чём код?
module.exports = (sequelize, DataTypes) => { const User = sequelize.define( 'User', { id: { type: DataTypes.INTEGER, primaryKey: true, autoIncrement: true, }, username: { type: DataTypes.STRING, allowNull: false, unique: true, validate: { len: [3, 25], }, }, email: { type: DataTypes.STRING, allowNull: false, unique: true, validate: { isEmail: true, }, }, password: { type: DataTypes.STRING, allowNull: false, validate: { len: [6, 100], }, }, role: { type: DataTypes.ENUM('user', 'moderator', 'admin'), allowNull: false, defaultValue: 'user', }, isActive: { type: DataTypes.BOOLEAN, allowNull: false, defaultValue: true, }, profilePicture: { type: DataTypes.STRING, allowNull: true, }, status: { type: DataTypes.TEXT, allowNull: true, }, tag:{ type:DataTypes.TEXT, allowNull: true, } }, { timestamps: true, } ); User.associate = (models) => { User.hasMany(models.ServerMember, { foreignKey: 'userId', as: 'serverMembers', }); User.belongsToMany(models.Server, { through: models.ServerMember, foreignKey: 'userId', otherKey: 'serverId', as: 'servers', }); }; return User; };