audiobookshelf/server/models/MediaFile.js

29 lines
713 B
JavaScript
Raw Normal View History

2023-03-15 23:42:35 +01:00
const { DataTypes, Model } = require('sequelize')
module.exports = (sequelize) => {
class MediaFile extends Model { }
MediaFile.init({
id: {
type: DataTypes.UUID,
defaultValue: DataTypes.UUIDV4,
primaryKey: true
},
formatName: DataTypes.STRING,
formatNameLong: DataTypes.STRING,
duration: DataTypes.FLOAT,
bitrate: DataTypes.INTEGER,
size: DataTypes.BIGINT,
tags: DataTypes.JSON
}, {
sequelize,
2023-03-19 21:19:22 +01:00
modelName: 'mediaFile'
2023-03-15 23:42:35 +01:00
})
2023-03-19 21:19:22 +01:00
const { fileMetadata } = sequelize.models
2023-03-15 23:42:35 +01:00
2023-03-19 21:19:22 +01:00
fileMetadata.hasOne(MediaFile, { foreignKey: 'fileMetadataId' })
MediaFile.belongsTo(fileMetadata, { as: 'fileMetadata', foreignKey: 'fileMetadataId' })
2023-03-15 23:42:35 +01:00
return MediaFile
}