From d5a83d2ea1bdaebb6b427b779190c07c5cad93f4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=A1=B0=EB=8C=80=ED=9D=AC?= <joedaehui@ajou.ac.kr> Date: Fri, 15 Nov 2024 23:00:00 +0900 Subject: [PATCH] =?UTF-8?q?refactor:=20friend=20=EB=AA=A8=EB=8D=B8=20?= =?UTF-8?q?=EC=BB=AC=EB=9F=BC=20=EC=88=98=EC=A0=95=20(#7)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- models/Friend.js | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/models/Friend.js b/models/Friend.js index d9c41e2..d3d7131 100644 --- a/models/Friend.js +++ b/models/Friend.js @@ -5,19 +5,20 @@ const sequelize = require('../config/sequelize'); const User = require('./User'); const Friend = sequelize.define('Friend', { - type: { - type: DataTypes.ENUM('NORMAL', 'SPECIAL'), - allowNull: false, - }, + status: { + type: DataTypes.ENUM('PENDING', 'ACCEPTED'), + allowNull: false, + defaultValue: 'PENDING' + } }, { - tableName: 'Friends', - timestamps: true, + tableName: 'Friends', + timestamps: true, }); Friend.belongsTo(User, { foreignKey: 'user_id', as: 'user' }); Friend.belongsTo(User, { foreignKey: 'friend_id', as: 'friend' }); User.hasMany(Friend, { foreignKey: 'user_id', as: 'friends' }); -User.hasMany(Friend, { foreignKey: 'friend_id', as: 'friendOf' }); +User.hasMany(Friend, { foreignKey: 'friend_id', as: 'friendRequests' }); -module.exports = Friend; +module.exports = Friend; \ No newline at end of file -- GitLab