Duffer Derek
import Sequelize, { DataTypes } from "sequelize";
import dbConnection from "../config/database.js";
const sequelize = dbConnection;
const User = sequelize.define(
"users",
{
id: {
type: DataTypes.INTEGER,
allowNull: false,
autoIncrement: true,
primaryKey: true,
},
item_id: {
type: DataTypes.BIGINT,
allowNull: true,
defaultValue: null,
},
name: {
type: DataTypes.STRING(255),
allowNull: true,
},
firstname: {
type: DataTypes.STRING(255),
allowNull: true,
},
lastname: {
type: DataTypes.STRING(255),
allowNull: true,
},
task_activation_span: {
type: DataTypes.BIGINT,
allowNull: true,
},
region: {
type: DataTypes.BIGINT,
allowNull: true,
defaultValue: null,
},
email: {
type: DataTypes.STRING(255),
allowNull: true,
},
phone: {
type: DataTypes.STRING(20),
allowNull: true,
},
password: {
type: DataTypes.STRING(255),
allowNull: true,
},
type: {
type: DataTypes.TINYINT,
allowNull: true,
defaultValue: 0,
comment: "0=Partner, 1=Admin , 3=Office partner",
},
created_at: {
type: DataTypes.DATE,
allowNull: false,
},
updated_at: {
type: DataTypes.DATE,
allowNull: false,
},
status: {
type: DataTypes.TINYINT,
allowNull: true,
defaultValue: 1,
comment: "1=active, 2=inactive",
},
},
{
tableName: "users",
timestamps: true, // Enable timestamps
updatedAt: "updated_at", // Customize the updatedAt column name
createdAt: "created_at", // Customize the createdAt column name
defaultScope: {
where: {
status: 1,
},
order: [["region", "ASC"]],
},
}
);
export default User;
Sindbad File Manager Version 1.0, Coded By Sindbad EG ~ The Terrorists