first commit
This commit is contained in:
@@ -0,0 +1,55 @@
|
||||
/**
|
||||
* Copyright (c) 2026 Niolla
|
||||
* All rights reserved.
|
||||
*
|
||||
* This source code is proprietary and confidential.
|
||||
* Unauthorized copying, modification, distribution, or use
|
||||
* of this file, via any medium, is strictly prohibited.
|
||||
*/
|
||||
|
||||
// app/models/notification/notification.model.js
|
||||
|
||||
module.exports = (sequelize, DataTypes) => {
|
||||
const notification = sequelize.define(
|
||||
"notification",
|
||||
{
|
||||
notification_id: {
|
||||
type: DataTypes.STRING,
|
||||
primaryKey: true,
|
||||
},
|
||||
notificationHeadline: {
|
||||
type: DataTypes.STRING,
|
||||
allowNull: false,
|
||||
},
|
||||
notificationDescription: {
|
||||
type: DataTypes.TEXT,
|
||||
allowNull: true,
|
||||
},
|
||||
notificationType: {
|
||||
type: DataTypes.ENUM("USER", "ANNOUNCEMENT"),
|
||||
allowNull: false,
|
||||
},
|
||||
isActive: {
|
||||
type: DataTypes.BOOLEAN,
|
||||
defaultValue: true,
|
||||
},
|
||||
dateCreated: {
|
||||
type: DataTypes.DATE,
|
||||
defaultValue: DataTypes.NOW,
|
||||
},
|
||||
},
|
||||
{
|
||||
tableName: "notification",
|
||||
timestamps: true,
|
||||
},
|
||||
);
|
||||
|
||||
notification.associate = (models) => {
|
||||
notification.hasMany(models.userNotification, {
|
||||
foreignKey: "notification_id",
|
||||
as: "users",
|
||||
});
|
||||
};
|
||||
|
||||
return notification;
|
||||
};
|
||||
@@ -0,0 +1,54 @@
|
||||
/**
|
||||
* Copyright (c) 2026 Niolla
|
||||
* All rights reserved.
|
||||
*
|
||||
* This source code is proprietary and confidential.
|
||||
* Unauthorized copying, modification, distribution, or use
|
||||
* of this file, via any medium, is strictly prohibited.
|
||||
*/
|
||||
|
||||
// app/models/notification/userNotification.model.js
|
||||
|
||||
module.exports = (sequelize, DataTypes) => {
|
||||
const userNotification = sequelize.define(
|
||||
"userNotification",
|
||||
{
|
||||
id: {
|
||||
type: DataTypes.INTEGER,
|
||||
autoIncrement: true,
|
||||
primaryKey: true,
|
||||
},
|
||||
user_id: {
|
||||
type: DataTypes.STRING(255),
|
||||
allowNull: false,
|
||||
collate: "utf8mb4_general_ci",
|
||||
},
|
||||
notification_id: {
|
||||
type: DataTypes.STRING,
|
||||
allowNull: false,
|
||||
},
|
||||
isRead: {
|
||||
type: DataTypes.BOOLEAN,
|
||||
defaultValue: false,
|
||||
},
|
||||
},
|
||||
{
|
||||
tableName: "user_notification",
|
||||
timestamps: true,
|
||||
},
|
||||
);
|
||||
|
||||
userNotification.associate = (models) => {
|
||||
userNotification.belongsTo(models.User, {
|
||||
foreignKey: "user_id",
|
||||
constraints: false,
|
||||
});
|
||||
|
||||
userNotification.belongsTo(models.notification, {
|
||||
foreignKey: "notification_id",
|
||||
constraints: false,
|
||||
});
|
||||
};
|
||||
|
||||
return userNotification;
|
||||
};
|
||||
Reference in New Issue
Block a user