Remove old Author object & fix issue deleting empty authors

This commit is contained in:
advplyr 2024-08-31 13:27:48 -05:00
parent acc4bdbc5e
commit ba742563c2
13 changed files with 227 additions and 314 deletions

View file

@ -73,8 +73,7 @@ module.exports = {
})
const authorMatches = []
for (const author of authors) {
const oldAuthor = author.getOldAuthor().toJSON()
oldAuthor.numBooks = author.dataValues.numBooks
const oldAuthor = author.toOldJSONExpanded(author.dataValues.numBooks)
authorMatches.push(oldAuthor)
}
return authorMatches

View file

@ -353,7 +353,7 @@ module.exports = {
return {
authors: authors.map((au) => {
const numBooks = au.books.length || 0
return au.getOldAuthor().toJSONExpanded(numBooks)
return au.toOldJSONExpanded(numBooks)
}),
count
}
@ -409,7 +409,7 @@ module.exports = {
/**
* Get library items for an author, optional use user permissions
* @param {oldAuthor} author
* @param {import('../../models/Author')} author
* @param {import('../../models/User')} user
* @param {number} limit
* @param {number} offset