mirror of
https://github.com/advplyr/audiobookshelf.git
synced 2025-08-22 20:21:57 +02:00
Fix:Changing author name not updating library item metadata files #3060
This commit is contained in:
@@ -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
|
||||
|
Reference in New Issue
Block a user