2023-03-12 23:55:12 +01:00
|
|
|
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,
|
2023-03-19 21:19:22 +01:00
|
|
|
modelName: 'playlist'
|
2023-03-12 23:55:12 +01:00
|
|
|
})
|
|
|
|
|
2023-03-19 21:19:22 +01:00
|
|
|
const { library, user } = sequelize.models
|
|
|
|
library.hasMany(Playlist)
|
|
|
|
Playlist.belongsTo(library)
|
2023-03-12 23:55:12 +01:00
|
|
|
|
2023-03-19 21:19:22 +01:00
|
|
|
user.hasMany(Playlist)
|
|
|
|
Playlist.belongsTo(user)
|
2023-03-12 23:55:12 +01:00
|
|
|
|
|
|
|
return Playlist
|
|
|
|
}
|