import { Model, DataTypes, CreationOptional } from 'sequelize'; import { client as sequelize } from 'lib/DB/connection'; export class DNC extends Model { declare id: number; declare phone_number: string; declare source_code: string | null; declare vertical_id: string | null; declare company_id: string | null; declare state: string | null; declare createdAt: CreationOptional; declare updatedAt: CreationOptional; declare deletedAt: CreationOptional; } DNC.init( { id: { type: DataTypes.BIGINT, autoIncrement: true, primaryKey: true, }, phone_number: { type: DataTypes.STRING, allowNull: false, }, source_code: { type: DataTypes.STRING, allowNull: true, validate: { notEmpty: true, }, }, state: { type: DataTypes.STRING, allowNull: true, validate: { notEmpty: true, }, }, vertical_id: { type: DataTypes.STRING, allowNull: true, validate: { notEmpty: true, }, }, company_id: { type: DataTypes.STRING, allowNull: true, validate: { notEmpty: true, }, }, createdAt: DataTypes.DATE, updatedAt: DataTypes.DATE, deletedAt: DataTypes.DATE, }, { sequelize, paranoid: true, timestamps: true, tableName: 'dncs', scopes: { buyer(value: string) { return { where: { company_id: value, }, }; }, }, indexes: [], } );