Files
SSA-Chat-Backend/src/models/chatMedia.model.js
2025-06-23 18:55:08 +05:30

47 lines
1.3 KiB
JavaScript

const { Model, DataTypes } = require('sequelize');
module.exports = (sequelize) => {
class chatMedia extends Model {
static associate(models) {
this.belongsTo(models.chat, {
foreignKey: "chat_xid",
as: "media",
onDelete: "CASCADE",
});
}
}
chatMedia.init(
{
id: {
type: DataTypes.INTEGER,
primaryKey: true,
autoIncrement: true,
},
chat_xid: { type: DataTypes.INTEGER, allowNull: false, },
image_file_name: {
type: DataTypes.STRING,
allowNull: true,
},
image_path: {
type: DataTypes.STRING,
allowNull: true,
},
image_size: {
type: DataTypes.STRING,
allowNull: true,
},
is_active: {
type: DataTypes.BOOLEAN,
},
delivery_status: { type: DataTypes.ENUM('sent', 'delivered', 'read'), defaultValue: 'sent' },
},
{
sequelize,
tableName: 'chatMedia',
timestamps: true,
paranoid: true,
}
);
return chatMedia;
};