mirror of
https://github.com/advplyr/audiobookshelf.git
synced 2024-12-20 19:06:06 +01:00
26 lines
692 B
JavaScript
26 lines
692 B
JavaScript
const { DataTypes, Model } = require('sequelize')
|
|
|
|
module.exports = (sequelize) => {
|
|
class Person extends Model { }
|
|
|
|
Person.init({
|
|
id: {
|
|
type: DataTypes.UUID,
|
|
defaultValue: DataTypes.UUIDV4,
|
|
primaryKey: true
|
|
},
|
|
type: DataTypes.STRING,
|
|
name: DataTypes.STRING,
|
|
asin: DataTypes.STRING,
|
|
description: DataTypes.TEXT
|
|
}, {
|
|
sequelize,
|
|
modelName: 'Person'
|
|
})
|
|
|
|
const { FileMetadata } = sequelize.models
|
|
FileMetadata.hasMany(Person, { foreignKey: 'ImageFileId' })
|
|
Person.belongsTo(FileMetadata, { as: 'ImageFile', foreignKey: 'ImageFileId' }) // Ref: https://sequelize.org/docs/v6/core-concepts/assocs/#defining-an-alias
|
|
|
|
return Person
|
|
} |