audiobookshelf/server/models/LibraryFolder.js

48 lines
932 B
JavaScript
Raw Normal View History

2023-07-05 01:14:44 +02:00
const { DataTypes, Model } = require('sequelize')
2023-08-16 01:03:43 +02:00
class LibraryFolder extends Model {
constructor(values, options) {
super(values, options)
/** @type {UUIDV4} */
this.id
/** @type {string} */
this.path
/** @type {UUIDV4} */
this.libraryId
/** @type {Date} */
this.createdAt
/** @type {Date} */
this.updatedAt
}
/**
* Initialize model
* @param {import('../Database').sequelize} sequelize
2023-08-16 01:03:43 +02:00
*/
static init(sequelize) {
super.init(
{
id: {
type: DataTypes.UUID,
defaultValue: DataTypes.UUIDV4,
primaryKey: true
},
path: DataTypes.STRING
2023-08-16 01:03:43 +02:00
},
{
sequelize,
modelName: 'libraryFolder'
}
)
2023-07-05 01:14:44 +02:00
2023-08-16 01:03:43 +02:00
const { library } = sequelize.models
library.hasMany(LibraryFolder, {
onDelete: 'CASCADE'
})
LibraryFolder.belongsTo(library)
}
}
2023-07-05 01:14:44 +02:00
module.exports = LibraryFolder