diff --git a/server/Database.js b/server/Database.js index 9bce2605..9b9f9cf9 100644 --- a/server/Database.js +++ b/server/Database.js @@ -808,6 +808,28 @@ 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()