/
commondan
/
authapi
Обзор
Документация
Войти
/
commondan
/
authapi
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
master
src/models/user.model.js
60 строк
1 KB
CommondaN0
First initial commit of auth API for web-app
04 апр 2026, 20:13
04 апр 2026, 20:13
27b471c
Код
Авторство
О чём код?
import { DataTypes } from "sequelize"; const createUserModel = (sequelize) => { const User = sequelize.define( "User", { id: { type: DataTypes.UUID, defaultValue: DataTypes.UUIDV4, primaryKey: true, }, name: { type: DataTypes.STRING, allowNull: false, unique: true, validate: { notEmpty: true, len: [3, 50], }, }, email: { type: DataTypes.STRING, allowNull: false, unique: true, validate: { notEmpty: true, isEmail: true, }, }, password: { type: DataTypes.STRING, allowNull: false, }, role: { type: DataTypes.STRING, allowNull: false, defaultValue: "user", }, }, { tableName: "users", defaultScope: { attributes: { exclude: ["password"], }, }, scopes: { withPassword: { attributes: { include: ["password"], }, }, }, } ); return User; }; export default createUserModel;