audiobookshelf/server/models/LibraryFile.js

25 lines
621 B
JavaScript
Raw Normal View History

2023-03-12 20:51:45 +01:00
const { DataTypes, Model } = require('sequelize')
module.exports = (sequelize) => {
class LibraryFile extends Model { }
LibraryFile.init({
id: {
type: DataTypes.UUID,
defaultValue: DataTypes.UUIDV4,
primaryKey: true
}
}, {
sequelize,
modelName: 'LibraryFile'
})
const { LibraryItem, FileMetadata } = sequelize.models
LibraryItem.hasMany(LibraryFile)
LibraryFile.belongsTo(LibraryItem)
2023-03-18 22:56:57 +01:00
FileMetadata.hasOne(LibraryFile, { foreignKey: 'FileMetadataId' })
LibraryFile.belongsTo(FileMetadata, { as: 'FileMetadata', foreignKey: 'FileMetadataId' })
2023-03-12 20:51:45 +01:00
return LibraryFile
}