2019-10-17 16:00:50 +00:00
|
|
|
module.exports = function (sequelize, DataTypes) {
|
|
|
|
|
const Notification = sequelize.define('Notification', {
|
|
|
|
|
id: {
|
|
|
|
|
type: DataTypes.UUID,
|
|
|
|
|
defaultValue: DataTypes.UUIDV4,
|
|
|
|
|
primaryKey: true,
|
|
|
|
|
},
|
2019-10-31 12:45:18 +00:00
|
|
|
date: {
|
|
|
|
|
type: DataTypes.DATE,
|
|
|
|
|
allowNull: false,
|
|
|
|
|
},
|
2019-10-17 16:00:50 +00:00
|
|
|
title: {
|
|
|
|
|
type: DataTypes.STRING,
|
|
|
|
|
allowNull: true,
|
|
|
|
|
},
|
|
|
|
|
body: {
|
|
|
|
|
type: DataTypes.STRING,
|
|
|
|
|
allowNull: true,
|
|
|
|
|
},
|
|
|
|
|
ttl: {
|
|
|
|
|
type: DataTypes.INTEGER,
|
|
|
|
|
allowNull: true,
|
|
|
|
|
},
|
|
|
|
|
priority: {
|
|
|
|
|
type: DataTypes.STRING,
|
|
|
|
|
allowNull: false,
|
|
|
|
|
default: 'default',
|
|
|
|
|
},
|
|
|
|
|
data: {
|
|
|
|
|
type: DataTypes.JSON,
|
|
|
|
|
allowNull: true,
|
|
|
|
|
},
|
|
|
|
|
}, {
|
|
|
|
|
tableName: 'notifications',
|
|
|
|
|
freezeTableName: true,
|
|
|
|
|
timestamps: true,
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
Notification.associate = function (models) {
|
|
|
|
|
Notification.User = Notification.belongsTo(models.User, { foreignKey: 'userId', as: "user" });
|
|
|
|
|
Notification.Details = Notification.hasMany(models.NotificationDetail, { foreignKey: 'notificationId', as: 'details' });
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
return Notification;
|
|
|
|
|
};
|
|
|
|
|
|