mirror of
https://github.com/advplyr/audiobookshelf.git
synced 2024-12-20 19:06:06 +01:00
29 lines
713 B
JavaScript
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
|
|
} |