audiobookshelf/server/models/EBookFile.js
2023-03-19 15:19:22 -05:00

24 lines
554 B
JavaScript

const { DataTypes, Model } = require('sequelize')
module.exports = (sequelize) => {
class EBookFile extends Model { }
EBookFile.init({
id: {
type: DataTypes.UUID,
defaultValue: DataTypes.UUIDV4,
primaryKey: true
},
format: DataTypes.STRING
}, {
sequelize,
modelName: 'eBookFile'
})
const { fileMetadata } = sequelize.models
fileMetadata.hasOne(EBookFile, { foreignKey: 'fileMetadataId' })
EBookFile.belongsTo(fileMetadata, { as: 'fileMetadata', foreignKey: 'fileMetadataId' })
return EBookFile
}