67 lines
1.4 KiB
JavaScript
67 lines
1.4 KiB
JavaScript
|
|
import db from "../database/db.js";
|
||
|
|
|
||
|
|
const UserModel = (DataTypes) => {
|
||
|
|
const Users = db.define(
|
||
|
|
"users",
|
||
|
|
{
|
||
|
|
id: {
|
||
|
|
type: DataTypes.BIGINT,
|
||
|
|
primaryKey: true,
|
||
|
|
autoIncrement: true,
|
||
|
|
validate: {
|
||
|
|
notEmpty: true,
|
||
|
|
},
|
||
|
|
},
|
||
|
|
name: {
|
||
|
|
type: DataTypes.STRING,
|
||
|
|
allowNull: false,
|
||
|
|
validate: {
|
||
|
|
notEmpty: true,
|
||
|
|
},
|
||
|
|
},
|
||
|
|
email: {
|
||
|
|
type: DataTypes.STRING,
|
||
|
|
allowNull: false,
|
||
|
|
unique: true,
|
||
|
|
validate: {
|
||
|
|
notEmpty: true,
|
||
|
|
isEmail: true,
|
||
|
|
},
|
||
|
|
},
|
||
|
|
email_verified_at: {
|
||
|
|
type: DataTypes.DATE,
|
||
|
|
allowNull: true,
|
||
|
|
},
|
||
|
|
password: {
|
||
|
|
type: DataTypes.STRING,
|
||
|
|
allowNull: false,
|
||
|
|
},
|
||
|
|
roles: {
|
||
|
|
type: DataTypes.STRING,
|
||
|
|
allowNull: true,
|
||
|
|
},
|
||
|
|
remember_token: {
|
||
|
|
type: DataTypes.STRING(100),
|
||
|
|
allowNull: true,
|
||
|
|
},
|
||
|
|
created_at: {
|
||
|
|
type: DataTypes.DATE,
|
||
|
|
allowNull: true,
|
||
|
|
defaultValue: DataTypes.NOW,
|
||
|
|
},
|
||
|
|
updated_at: {
|
||
|
|
type: DataTypes.DATE,
|
||
|
|
allowNull: true,
|
||
|
|
defaultValue: DataTypes.NOW,
|
||
|
|
},
|
||
|
|
},
|
||
|
|
{
|
||
|
|
timestamps: false, // Disable Sequelize's automatic timestamp fields (createdAt, updatedAt)
|
||
|
|
tableName: "users", // Ensure the table name matches the actual table name
|
||
|
|
}
|
||
|
|
);
|
||
|
|
return Users;
|
||
|
|
};
|
||
|
|
|
||
|
|
export default UserModel;
|