mirror of
https://github.com/advplyr/audiobookshelf.git
synced 2026-03-04 15:09:44 +00:00
Update model casing & associations
This commit is contained in:
parent
2131a65299
commit
54ca58e610
45 changed files with 830 additions and 561 deletions
|
|
@ -12,21 +12,21 @@ module.exports = (sequelize) => {
|
|||
sequence: DataTypes.STRING
|
||||
}, {
|
||||
sequelize,
|
||||
modelName: 'BookSeries',
|
||||
modelName: 'bookSeries',
|
||||
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, Series } = sequelize.models
|
||||
Book.belongsToMany(Series, { through: BookSeries })
|
||||
Series.belongsToMany(Book, { through: BookSeries })
|
||||
const { book, series } = sequelize.models
|
||||
book.belongsToMany(series, { through: BookSeries })
|
||||
series.belongsToMany(book, { through: BookSeries })
|
||||
|
||||
Book.hasMany(BookSeries)
|
||||
BookSeries.belongsTo(Book)
|
||||
book.hasMany(BookSeries)
|
||||
BookSeries.belongsTo(book)
|
||||
|
||||
Series.hasMany(BookSeries)
|
||||
BookSeries.belongsTo(Series)
|
||||
series.hasMany(BookSeries)
|
||||
BookSeries.belongsTo(series)
|
||||
|
||||
return BookSeries
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue