New model updates for series, collections, authors routes

This commit is contained in:
advplyr 2022-03-12 18:50:31 -06:00
parent 73257188f6
commit 2d19208340
19 changed files with 432 additions and 247 deletions

View file

@ -37,10 +37,10 @@ class UserCollection {
}
}
toJSONExpanded(audiobooks, minifiedBooks = false) {
toJSONExpanded(libraryItems, minifiedBooks = false) {
var json = this.toJSON()
json.books = json.books.map(bookId => {
var _ab = audiobooks.find(ab => ab.id === bookId)
var _ab = libraryItems.find(li => li.id === bookId)
return _ab ? minifiedBooks ? _ab.toJSONMinified() : _ab.toJSONExpanded() : null
}).filter(b => !!b)
return json

View file

@ -99,11 +99,11 @@ class BookMetadata {
return this.title + '&' + this.authorName
}
hasAuthor(authorName) {
return !!this.authors.find(au => au.name == authorName)
hasAuthor(id) {
return !!this.authors.find(au => au.id == id)
}
hasSeries(seriesName) {
return !!this.series.find(se => se.name == seriesName)
hasSeries(seriesId) {
return !!this.series.find(se => se.id == seriesId)
}
hasNarrator(narratorName) {
return this.narrators.includes(narratorName)