mirror of
https://github.com/advplyr/audiobookshelf.git
synced 2024-12-20 19:06:06 +01:00
33 lines
824 B
JavaScript
33 lines
824 B
JavaScript
|
const { DataTypes, Model } = require('sequelize')
|
||
|
|
||
|
module.exports = (sequelize) => {
|
||
|
class Notification extends Model { }
|
||
|
|
||
|
Notification.init({
|
||
|
id: {
|
||
|
type: DataTypes.UUID,
|
||
|
defaultValue: DataTypes.UUIDV4,
|
||
|
primaryKey: true
|
||
|
},
|
||
|
eventName: DataTypes.STRING,
|
||
|
urls: DataTypes.TEXT, // JSON array of urls
|
||
|
titleTemplate: DataTypes.STRING(1000),
|
||
|
bodyTemplate: DataTypes.TEXT,
|
||
|
type: DataTypes.STRING,
|
||
|
lastFiredAt: DataTypes.DATE,
|
||
|
lastAttemptFailed: DataTypes.BOOLEAN,
|
||
|
numConsecutiveFailedAttempts: DataTypes.INTEGER,
|
||
|
numTimesFired: DataTypes.INTEGER,
|
||
|
enabled: DataTypes.BOOLEAN
|
||
|
}, {
|
||
|
sequelize,
|
||
|
modelName: 'Notification'
|
||
|
})
|
||
|
|
||
|
const { Library } = sequelize.models
|
||
|
|
||
|
Library.hasMany(Notification)
|
||
|
Notification.belongsTo(Library)
|
||
|
|
||
|
return Notification
|
||
|
}
|