mirror of
https://github.com/advplyr/audiobookshelf.git
synced 2025-07-31 08:14:40 +02:00
This commit is contained in:
parent
03963aa9a1
commit
b9dee8704f
5 changed files with 93 additions and 38 deletions
39
server/Db.js
39
server/Db.js
|
@ -82,10 +82,14 @@ class Db {
|
|||
await this.load()
|
||||
|
||||
// Insert Defaults
|
||||
if (!this.users.find(u => u.type === 'root')) {
|
||||
var rootUser = this.users.find(u => u.type === 'root')
|
||||
if (!rootUser) {
|
||||
var token = await jwt.sign({ userId: 'root' }, process.env.TOKEN_SECRET)
|
||||
Logger.debug('Generated default token', token)
|
||||
Logger.info('[Db] Root user created')
|
||||
await this.insertEntity('user', this.getDefaultUser(token))
|
||||
} else {
|
||||
Logger.info(`[Db] Root user exists, pw: ${rootUser.hasPw}`)
|
||||
}
|
||||
|
||||
if (!this.libraries.length) {
|
||||
|
@ -123,19 +127,6 @@ class Db {
|
|||
await Promise.all([p1, p2, p3, p4])
|
||||
}
|
||||
|
||||
// insertAudiobook(audiobook) {
|
||||
// return this.insertAudiobooks([audiobook])
|
||||
// }
|
||||
|
||||
// insertAudiobooks(audiobooks) {
|
||||
// return this.audiobooksDb.insert(audiobooks).then((results) => {
|
||||
// Logger.debug(`[DB] Inserted ${results.inserted} audiobooks`)
|
||||
// this.audiobooks = this.audiobooks.concat(audiobooks)
|
||||
// }).catch((error) => {
|
||||
// Logger.error(`[DB] Insert audiobooks Failed ${error}`)
|
||||
// })
|
||||
// }
|
||||
|
||||
updateAudiobook(audiobook) {
|
||||
return this.audiobooksDb.update((record) => record.id === audiobook.id, () => audiobook).then((results) => {
|
||||
Logger.debug(`[DB] Audiobook updated ${results.updated}`)
|
||||
|
@ -146,26 +137,6 @@ class Db {
|
|||
})
|
||||
}
|
||||
|
||||
// insertUser(user) {
|
||||
// return this.usersDb.insert([user]).then((results) => {
|
||||
// Logger.debug(`[DB] Inserted user ${results.inserted}`)
|
||||
// this.users.push(user)
|
||||
// return true
|
||||
// }).catch((error) => {
|
||||
// Logger.error(`[DB] Insert user Failed ${error}`)
|
||||
// return false
|
||||
// })
|
||||
// }
|
||||
|
||||
// insertSettings(settings) {
|
||||
// return this.settingsDb.insert([settings]).then((results) => {
|
||||
// Logger.debug(`[DB] Inserted ${results.inserted} settings`)
|
||||
// this.settings = this.settings.concat(settings)
|
||||
// }).catch((error) => {
|
||||
// Logger.error(`[DB] Insert settings Failed ${error}`)
|
||||
// })
|
||||
// }
|
||||
|
||||
updateUserStream(userId, streamId) {
|
||||
return this.usersDb.update((record) => record.id === userId, (user) => {
|
||||
user.stream = streamId
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue