mirror of
https://github.com/advplyr/audiobookshelf.git
synced 2025-01-08 00:08:14 +01:00
25 lines
621 B
JavaScript
25 lines
621 B
JavaScript
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)
|
|
|
|
FileMetadata.hasOne(LibraryFile, { foreignKey: 'FileMetadataId' })
|
|
LibraryFile.belongsTo(FileMetadata, { as: 'FileMetadata', foreignKey: 'FileMetadataId' })
|
|
|
|
return LibraryFile
|
|
} |