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,
modelName: 'MediaFile'
})
const { FileMetadata } = sequelize.models
2023-03-18 22:56:57 +01:00
FileMetadata.hasOne(MediaFile, { foreignKey: 'FileMetadataId' })
MediaFile.belongsTo(FileMetadata, { as: 'FileMetadata', foreignKey: 'FileMetadataId' })
2023-03-15 23:42:35 +01:00
return MediaFile
}