mirror of
https://github.com/advplyr/audiobookshelf.git
synced 2026-06-09 04:02:42 +02:00
Update model casing & associations
This commit is contained in:
@@ -11,21 +11,21 @@ module.exports = (sequelize) => {
|
||||
}
|
||||
}, {
|
||||
sequelize,
|
||||
modelName: 'BookGenre',
|
||||
modelName: 'bookGenre',
|
||||
timestamps: false
|
||||
})
|
||||
|
||||
// Super Many-to-Many
|
||||
// ref: https://sequelize.org/docs/v6/advanced-association-concepts/advanced-many-to-many/#the-best-of-both-worlds-the-super-many-to-many-relationship
|
||||
const { Book, Genre } = sequelize.models
|
||||
Book.belongsToMany(Genre, { through: BookGenre })
|
||||
Genre.belongsToMany(Book, { through: BookGenre })
|
||||
const { book, genre } = sequelize.models
|
||||
book.belongsToMany(genre, { through: BookGenre })
|
||||
genre.belongsToMany(book, { through: BookGenre })
|
||||
|
||||
Book.hasMany(BookGenre)
|
||||
BookGenre.belongsTo(Book)
|
||||
book.hasMany(BookGenre)
|
||||
BookGenre.belongsTo(book)
|
||||
|
||||
Genre.hasMany(BookGenre)
|
||||
BookGenre.belongsTo(Genre)
|
||||
genre.hasMany(BookGenre)
|
||||
BookGenre.belongsTo(genre)
|
||||
|
||||
return BookGenre
|
||||
}
|
||||
Reference in New Issue
Block a user