Fix:Changing author name not updating library item metadata files #3060

This commit is contained in:
advplyr 2024-06-27 16:32:38 -05:00
parent 8cadaa57f6
commit 56c0124c13
3 changed files with 106 additions and 13 deletions

View file

@ -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