audiobookshelf/server/models/MediaFile.js
2023-03-18 16:56:57 -05:00

29 lines
713 B
JavaScript

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,
modelName: 'MediaFile'
})
const { FileMetadata } = sequelize.models
FileMetadata.hasOne(MediaFile, { foreignKey: 'FileMetadataId' })
MediaFile.belongsTo(FileMetadata, { as: 'FileMetadata', foreignKey: 'FileMetadataId' })
return MediaFile
}