audiobookshelf/server/models/Playlist.js

27 lines
535 B
JavaScript
Raw Permalink Normal View History

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