Update library collections api endpoint to use libraryItems from db

This commit is contained in:
advplyr 2023-08-11 17:49:06 -05:00
parent aac2879652
commit 38029d1202
8 changed files with 209 additions and 31 deletions

View file

@ -661,13 +661,23 @@ module.exports = (sequelize) => {
* Get book library items for author, optional use user permissions
* @param {oldAuthor} author
* @param {[oldUser]} user
* @returns {oldLibraryItem[]}
* @returns {Promise<oldLibraryItem[]>}
*/
static async getForAuthor(author, user = null) {
const { libraryItems } = await libraryFilters.getLibraryItemsForAuthor(author, user, undefined, undefined)
return libraryItems.map(li => this.getOldLibraryItem(li))
}
/**
* Get book library items in a collection
* @param {oldCollection} collection
* @returns {Promise<oldLibraryItem[]>}
*/
static async getForCollection(collection) {
const libraryItems = await libraryFilters.getLibraryItemsForCollection(collection)
return libraryItems.map(li => this.getOldLibraryItem(li))
}
getMedia(options) {
if (!this.mediaType) return Promise.resolve(null)
const mixinMethodName = `get${sequelize.uppercaseFirst(this.mediaType)}`