2019-10-17 16:00:50 +00:00
|
|
|
module.exports = function (sequelize, DataTypes) {
|
|
|
|
|
const NotificationDetail = sequelize.define('NotificationDetail', {
|
|
|
|
|
id: {
|
|
|
|
|
type: DataTypes.UUID,
|
|
|
|
|
defaultValue: DataTypes.UUIDV4,
|
|
|
|
|
primaryKey: true,
|
|
|
|
|
},
|
|
|
|
|
token: {
|
|
|
|
|
type: DataTypes.STRING,
|
|
|
|
|
allowNull: false,
|
|
|
|
|
},
|
|
|
|
|
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,
|
|
|
|
|
},
|
|
|
|
|
ticket: {
|
|
|
|
|
type: DataTypes.STRING,
|
2019-10-21 18:23:06 +00:00
|
|
|
allowNull: true,
|
2019-10-17 16:00:50 +00:00
|
|
|
},
|
|
|
|
|
deliveryDate: {
|
|
|
|
|
type: DataTypes.DATE,
|
|
|
|
|
allowNull: false,
|
|
|
|
|
default: DataTypes.NOW,
|
|
|
|
|
},
|
|
|
|
|
deliveryStatus: {
|
|
|
|
|
type: DataTypes.STRING,
|
|
|
|
|
allowNull: true,
|
|
|
|
|
},
|
|
|
|
|
receiptDate: {
|
|
|
|
|
type: DataTypes.DATE,
|
|
|
|
|
allowNull: true,
|
|
|
|
|
},
|
|
|
|
|
receiptStatus: {
|
|
|
|
|
type: DataTypes.STRING,
|
|
|
|
|
allowNull: true,
|
|
|
|
|
},
|
|
|
|
|
}, {
|
|
|
|
|
tableName: 'notifications_details',
|
|
|
|
|
freezeTableName: true,
|
|
|
|
|
timestamps: true,
|
|
|
|
|
});
|
|
|
|
|
|
2019-10-21 09:38:47 +00:00
|
|
|
NotificationDetail.addScope('onlyWithoutReceipt', () => {
|
|
|
|
|
return {
|
|
|
|
|
where: {
|
|
|
|
|
receiptDate: { [Sequelize.Op.ne]: null }
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
2019-10-17 16:00:50 +00:00
|
|
|
NotificationDetail.associate = function (models) {
|
|
|
|
|
NotificationDetail.User = NotificationDetail.belongsTo(models.User, { foreignKey: 'userId', as: "user" });
|
|
|
|
|
//NotificationDetail.Notification = NotificationDetail.belongsTo(models.Notification, { foreignKey: 'notificationId', as: "user" });
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
return NotificationDetail;
|
|
|
|
|
};
|
|
|
|
|
|