2023-03-12 20:51:45 +01:00
|
|
|
const { DataTypes, Model } = require('sequelize')
|
|
|
|
|
|
|
|
module.exports = (sequelize) => {
|
|
|
|
class Collection extends Model { }
|
|
|
|
|
|
|
|
Collection.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: 'collection'
|
2023-03-12 20:51:45 +01:00
|
|
|
})
|
|
|
|
|
2023-03-19 21:19:22 +01:00
|
|
|
const { library } = sequelize.models
|
2023-03-12 20:51:45 +01:00
|
|
|
|
2023-03-19 21:19:22 +01:00
|
|
|
library.hasMany(Collection)
|
|
|
|
Collection.belongsTo(library)
|
2023-03-12 20:51:45 +01:00
|
|
|
|
|
|
|
return Collection
|
|
|
|
}
|