mirror of
https://github.com/advplyr/audiobookshelf.git
synced 2025-08-02 01:05:25 +02:00
Update functions for #2724 and add jsdocs
This commit is contained in:
parent
ae0a9bcf86
commit
c14f9accaf
2 changed files with 33 additions and 19 deletions
|
@ -689,19 +689,33 @@ class Database {
|
|||
return this.libraryFilterData[libraryId].series.some(se => se.id === seriesId)
|
||||
}
|
||||
|
||||
async getAuthorByName(libraryId, authorName) {
|
||||
/**
|
||||
* Get author id for library by name. Uses library filter data if available
|
||||
*
|
||||
* @param {string} libraryId
|
||||
* @param {string} authorName
|
||||
* @returns {Promise<string>} author id or null if not found
|
||||
*/
|
||||
async getAuthorIdByName(libraryId, authorName) {
|
||||
if (!this.libraryFilterData[libraryId]) {
|
||||
return await this.authorModel.getOldByNameAndLibrary(authorName, libraryId)
|
||||
return (await this.authorModel.getOldByNameAndLibrary(authorName, libraryId))?.id || null
|
||||
}
|
||||
return this.libraryFilterData[libraryId].authors.find(au => au.name === authorName)
|
||||
return this.libraryFilterData[libraryId].authors.find(au => au.name === authorName)?.id || null
|
||||
}
|
||||
|
||||
async getSeriesByName(libraryId, seriesName) {
|
||||
/**
|
||||
* Get series id for library by name. Uses library filter data if available
|
||||
*
|
||||
* @param {string} libraryId
|
||||
* @param {string} seriesName
|
||||
* @returns {Promise<string>} series id or null if not found
|
||||
*/
|
||||
async getSeriesIdByName(libraryId, seriesName) {
|
||||
if (!this.libraryFilterData[libraryId]) {
|
||||
return await this.seriesModel.getOldByNameAndLibrary(seriesName, libraryId)
|
||||
return (await this.seriesModel.getOldByNameAndLibrary(seriesName, libraryId))?.id || null
|
||||
}
|
||||
return this.libraryFilterData[libraryId].series.find(se => se.name === seriesName)
|
||||
}
|
||||
return this.libraryFilterData[libraryId].series.find(se => se.name === seriesName)?.id || null
|
||||
}
|
||||
|
||||
/**
|
||||
* Reset numIssues for library
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue