Move cover path func to LibraryItem model

This commit is contained in:
advplyr 2024-11-02 12:56:40 -05:00
parent c25acb41fa
commit 7a1623e6a1
5 changed files with 30 additions and 25 deletions

View file

@ -808,28 +808,6 @@ class Database {
return `${normalizedColumn} LIKE ${pattern}`
}
}
async getLibraryItemCoverPath(libraryItemId) {
const libraryItem = await this.libraryItemModel.findByPk(libraryItemId, {
attributes: ['id', 'mediaType', 'mediaId', 'libraryId'],
include: [
{
model: this.bookModel,
attributes: ['id', 'coverPath']
},
{
model: this.podcastModel,
attributes: ['id', 'coverPath']
}
]
})
if (!libraryItem) {
Logger.warn(`[Database] getCover: Library item "${libraryItemId}" does not exist`)
return null
}
return libraryItem.media.coverPath
}
}
module.exports = new Database()