audiobookshelf/server/models/Playlist.js
2023-03-19 15:19:22 -05:00

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
}