Skip to content
Snippets Groups Projects
Commit d5a83d2e authored by 조대희's avatar 조대희
Browse files

refactor: friend 모델 컬럼 수정 (#7)

parent f8501f60
No related branches found
No related tags found
2 merge requests!31Develop,!8[#7] Friend 서비스 로직 개발
......@@ -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
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment