24 lines
564 B
JavaScript
24 lines
564 B
JavaScript
const { DataTypes } = require("sequelize");
|
|
const sequelize = require("../util/database");
|
|
|
|
const Comment = sequelize.define("Comment", {
|
|
id: { type: DataTypes.INTEGER, primaryKey: true, autoIncrement: true, allowNull: false },
|
|
body: { type: DataTypes.TEXT, allowNull: false }
|
|
}, {
|
|
sequelize,
|
|
timestamps: true,
|
|
modelName: 'Comment',
|
|
tableName: 'comment',
|
|
createdAt: true,
|
|
updatedAt: true
|
|
});
|
|
|
|
Comment.prototype.toJSONFor = function () {
|
|
return {
|
|
id: this.id,
|
|
body: this.body
|
|
};
|
|
};
|
|
|
|
module.exports = Comment;
|