audiobookshelf/server/models/Podcast.js

43 lines
1.2 KiB
JavaScript
Raw Normal View History

2023-03-12 20:51:45 +01:00
const { DataTypes, Model } = require('sequelize')
module.exports = (sequelize) => {
class Podcast extends Model { }
Podcast.init({
id: {
type: DataTypes.UUID,
defaultValue: DataTypes.UUIDV4,
primaryKey: true
},
title: DataTypes.STRING,
author: DataTypes.STRING,
releaseDate: DataTypes.STRING,
2023-03-18 22:56:57 +01:00
feedURL: DataTypes.STRING,
imageURL: DataTypes.STRING,
2023-03-12 20:51:45 +01:00
description: DataTypes.TEXT,
2023-03-18 22:56:57 +01:00
itunesPageURL: DataTypes.STRING,
2023-03-12 20:51:45 +01:00
itunesId: DataTypes.STRING,
itunesArtistId: DataTypes.STRING,
language: DataTypes.STRING,
2023-03-18 22:56:57 +01:00
podcastType: DataTypes.STRING,
2023-03-12 20:51:45 +01:00
explicit: DataTypes.BOOLEAN,
autoDownloadEpisodes: DataTypes.BOOLEAN,
autoDownloadSchedule: DataTypes.STRING,
lastEpisodeCheck: DataTypes.DATE,
maxEpisodesToKeep: DataTypes.INTEGER,
maxNewEpisodesToDownload: DataTypes.INTEGER,
lastCoverSearchQuery: DataTypes.STRING,
lastCoverSearch: DataTypes.DATE
}, {
sequelize,
2023-03-19 21:19:22 +01:00
modelName: 'podcast'
2023-03-12 20:51:45 +01:00
})
2023-03-19 21:19:22 +01:00
const { fileMetadata } = sequelize.models
2023-03-12 20:51:45 +01:00
2023-03-19 21:19:22 +01:00
fileMetadata.hasOne(Podcast, { foreignKey: 'imageFileId' })
Podcast.belongsTo(fileMetadata, { as: 'imageFile', foreignKey: 'imageFileId' }) // Ref: https://sequelize.org/docs/v6/core-concepts/assocs/#defining-an-alias
2023-03-12 20:51:45 +01:00
return Podcast
}