add Database.getLibraryItemCoverPath

This commit is contained in:
mikiher 2024-11-02 09:02:23 +02:00
parent 50fd659749
commit 431ae97593

View File

@ -808,6 +808,28 @@ class Database {
return `${normalizedColumn} LIKE ${pattern}` 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() module.exports = new Database()