audiobookshelf/server/models/EBookFile.js

24 lines
554 B
JavaScript
Raw Permalink Normal View History

2023-03-12 20:51:45 +01:00
const { DataTypes, Model } = require('sequelize')
module.exports = (sequelize) => {
class EBookFile extends Model { }
EBookFile.init({
id: {
type: DataTypes.UUID,
defaultValue: DataTypes.UUIDV4,
primaryKey: true
2023-03-19 21:19:22 +01:00
},
format: DataTypes.STRING
2023-03-12 20:51:45 +01:00
}, {
sequelize,
2023-03-19 21:19:22 +01:00
modelName: 'eBookFile'
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(EBookFile, { foreignKey: 'fileMetadataId' })
EBookFile.belongsTo(fileMetadata, { as: 'fileMetadata', foreignKey: 'fileMetadataId' })
2023-03-12 20:51:45 +01:00
return EBookFile
}