mirror of
https://github.com/advplyr/audiobookshelf.git
synced 2026-07-16 06:11:38 +00:00
automatically quickmatch new authors
This commit is contained in:
parent
753ae3d7dc
commit
060cfe6e86
4 changed files with 97 additions and 58 deletions
|
|
@ -1,4 +1,5 @@
|
|||
const { DataTypes, Model, where, fn, col } = require('sequelize')
|
||||
const { nameToLastFirst } = require('../utils/parsers/parseNameString')
|
||||
|
||||
const oldAuthor = require('../objects/entities/Author')
|
||||
|
||||
|
|
@ -166,6 +167,12 @@ class Author extends Model {
|
|||
onDelete: 'CASCADE'
|
||||
})
|
||||
Author.belongsTo(library)
|
||||
|
||||
Author.addHook('beforeCreate', async (author) => {
|
||||
if (!author || author.lastFirst) return
|
||||
author.lastFirst = nameToLastFirst(author.name)
|
||||
})
|
||||
|
||||
}
|
||||
}
|
||||
module.exports = Author
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue