const { DataTypes } = require('sequelize'); const sequelize = require('../config'); const Chapter = require('./chapter'); const Manga = sequelize.define('Manga', { connectorId: { type: DataTypes.STRING, allowNull: false, }, connectorName: { type: DataTypes.STRING, allowNull: false, }, title: { type: DataTypes.TEXT, allowNull: false, }, imageUrl: { type: DataTypes.TEXT, allowNull: false, }, linkChapter: { type: DataTypes.TEXT, allowNull: false, }, isFavorite: { type: DataTypes.BOOLEAN, defaultValue: false, }, description: { type: DataTypes.TEXT, allowNull: false, }, categories: { type: DataTypes.JSON, // Stocke la liste des catégories allowNull: false, }, rate: { type: DataTypes.TEXT, defaultValue: '0', }, }); Manga.hasMany(Chapter, { as: 'chapters', foreignKey: 'mangaId' }); Chapter.belongsTo(Manga, { foreignKey: 'mangaId' }); module.exports = Manga;