mirror of
https://github.com/advplyr/audiobookshelf.git
synced 2025-08-01 16:54:59 +02:00
Fix:Changing author name not updating library item metadata files #3060
This commit is contained in:
parent
8cadaa57f6
commit
56c0124c13
3 changed files with 106 additions and 13 deletions
|
@ -120,6 +120,50 @@ class Author extends Model {
|
|||
return author
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param {string} authorId
|
||||
* @returns {Promise<import('./LibraryItem')[]>}
|
||||
*/
|
||||
static async getAllLibraryItemsForAuthor(authorId) {
|
||||
const author = await this.findByPk(authorId, {
|
||||
include: [
|
||||
{
|
||||
model: this.sequelize.models.book,
|
||||
include: [
|
||||
{
|
||||
model: this.sequelize.models.libraryItem
|
||||
},
|
||||
{
|
||||
model: this.sequelize.models.author,
|
||||
through: {
|
||||
attributes: []
|
||||
}
|
||||
},
|
||||
{
|
||||
model: this.sequelize.models.series,
|
||||
through: {
|
||||
attributes: ['sequence']
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
})
|
||||
|
||||
const libraryItems = []
|
||||
if (author.books) {
|
||||
for (const book of author.books) {
|
||||
const libraryItem = book.libraryItem
|
||||
libraryItem.media = book
|
||||
delete book.libraryItem
|
||||
libraryItems.push(libraryItem)
|
||||
}
|
||||
}
|
||||
|
||||
return libraryItems
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize model
|
||||
* @param {import('../Database').sequelize} sequelize
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue