mirror of
https://github.com/advplyr/audiobookshelf.git
synced 2025-12-15 08:19:37 +00:00
Updates to use new Library model
This commit is contained in:
parent
8774e6be71
commit
38edcdca4b
6 changed files with 114 additions and 57 deletions
|
|
@ -43,6 +43,8 @@ class Library extends Model {
|
|||
this.createdAt
|
||||
/** @type {Date} */
|
||||
this.updatedAt
|
||||
/** @type {import('./LibraryFolder')[]|undefined} */
|
||||
this.libraryFolders
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -74,6 +76,28 @@ class Library extends Model {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @returns {Promise<Library[]>}
|
||||
*/
|
||||
static getAllWithFolders() {
|
||||
return this.findAll({
|
||||
include: this.sequelize.models.libraryFolder,
|
||||
order: [['displayOrder', 'ASC']]
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param {string} libraryId
|
||||
* @returns {Promise<Library>}
|
||||
*/
|
||||
static findByIdWithFolders(libraryId) {
|
||||
return this.findByPk(libraryId, {
|
||||
include: this.sequelize.models.libraryFolder
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all old libraries
|
||||
* @returns {Promise<oldLibrary[]>}
|
||||
|
|
@ -121,7 +145,7 @@ class Library extends Model {
|
|||
/**
|
||||
* Update library and library folders
|
||||
* @param {object} oldLibrary
|
||||
* @returns
|
||||
* @returns {Promise<Library|null>}
|
||||
*/
|
||||
static async updateFromOld(oldLibrary) {
|
||||
const existingLibrary = await this.findByPk(oldLibrary.id, {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue