mirror of
https://github.com/advplyr/audiobookshelf.git
synced 2025-06-26 02:39:05 +02:00
Update:Only load collections when needed
This commit is contained in:
parent
354e16e462
commit
5a9eed0a5a
8 changed files with 87 additions and 24 deletions
|
@ -20,9 +20,10 @@ class CollectionController {
|
|||
res.json(jsonExpanded)
|
||||
}
|
||||
|
||||
findAll(req, res) {
|
||||
async findAll(req, res) {
|
||||
const collections = await Database.models.collection.getOldCollections()
|
||||
res.json({
|
||||
collections: Database.collections.map(c => c.toJSONExpanded(Database.libraryItems))
|
||||
collections: collections.map(c => c.toJSONExpanded(Database.libraryItems))
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -160,9 +161,9 @@ class CollectionController {
|
|||
res.json(collection.toJSONExpanded(Database.libraryItems))
|
||||
}
|
||||
|
||||
middleware(req, res, next) {
|
||||
async middleware(req, res, next) {
|
||||
if (req.params.id) {
|
||||
const collection = Database.collections.find(c => c.id === req.params.id)
|
||||
const collection = await Database.models.collection.getById(req.params.id)
|
||||
if (!collection) {
|
||||
return res.status(404).send('Collection not found')
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue