Mise à jour de routes et models

This commit is contained in:
Rampeur
2025-08-10 09:15:18 +02:00
parent 61fdac2434
commit b68dd4c800
28 changed files with 1211 additions and 617 deletions
+22 -32
View File
@@ -1,35 +1,25 @@
const {
Model
} = require('sequelize');
module.exports = (sequelize, DataTypes) => {
class Comment extends Model {
/**
* Helper method for defining associations.
* This method is not a part of Sequelize lifecycle.
* The `models/index` file will call this method automatically.
*/
static associate(models) {
/* define association here */
}
}
Comment.init({
comment_id: { type: DataTypes.INTEGER, primaryKey: true, autoIncrement: true, allowNull: false },
comment_body: { type: DataTypes.TEXT, allowNull: false }
}, {
sequelize,
timestamps: false,
modelName: 'Comment',
tableName: 'comment',
createdAt: true,
updatedAt: true
});
const { DataTypes, Model } = require("sequelize");
const sequelize = require("../util/database");
Comment.prototype.toJSONFor = function () {
return {
id: this.comment_id,
body: this.comment_body
};
const Comment = sequelize.define("Comment", {
id: { type: DataTypes.INTEGER, primaryKey: true, autoIncrement: true, allowNull: false },
body: { type: DataTypes.TEXT, allowNull: false },
createdAt: { type: DataTypes.DATE, allowNull: true },
updatedAt: { type: DataTypes.DATE, allowNull: true }
}, {
sequelize,
timestamps: false,
modelName: 'Comment',
tableName: 'comment',
createdAt: true,
updatedAt: true
});
Comment.prototype.toJSONFor = function () {
return {
id: this.id,
body: this.body
};
};
return Comment;
};
module.exports = Comment;