mirror of
https://github.com/advplyr/audiobookshelf.git
synced 2024-12-20 19:06:06 +01:00
27 lines
535 B
JavaScript
27 lines
535 B
JavaScript
const { DataTypes, Model } = require('sequelize')
|
|
|
|
module.exports = (sequelize) => {
|
|
class Playlist extends Model { }
|
|
|
|
Playlist.init({
|
|
id: {
|
|
type: DataTypes.UUID,
|
|
defaultValue: DataTypes.UUIDV4,
|
|
primaryKey: true
|
|
},
|
|
name: DataTypes.STRING,
|
|
description: DataTypes.TEXT
|
|
}, {
|
|
sequelize,
|
|
modelName: 'Playlist'
|
|
})
|
|
|
|
const { Library, User } = sequelize.models
|
|
Library.hasMany(Playlist)
|
|
Playlist.belongsTo(Library)
|
|
|
|
User.hasMany(Playlist)
|
|
Playlist.belongsTo(User)
|
|
|
|
return Playlist
|
|
} |