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

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

parent f8501f60
Branches
No related tags found
2 merge requests!31Develop,!8[#7] Friend 서비스 로직 개발
...@@ -5,19 +5,20 @@ const sequelize = require('../config/sequelize'); ...@@ -5,19 +5,20 @@ const sequelize = require('../config/sequelize');
const User = require('./User'); const User = require('./User');
const Friend = sequelize.define('Friend', { const Friend = sequelize.define('Friend', {
type: { status: {
type: DataTypes.ENUM('NORMAL', 'SPECIAL'), type: DataTypes.ENUM('PENDING', 'ACCEPTED'),
allowNull: false, allowNull: false,
}, defaultValue: 'PENDING'
}
}, { }, {
tableName: 'Friends', tableName: 'Friends',
timestamps: true, timestamps: true,
}); });
Friend.belongsTo(User, { foreignKey: 'user_id', as: 'user' }); Friend.belongsTo(User, { foreignKey: 'user_id', as: 'user' });
Friend.belongsTo(User, { foreignKey: 'friend_id', as: 'friend' }); Friend.belongsTo(User, { foreignKey: 'friend_id', as: 'friend' });
User.hasMany(Friend, { foreignKey: 'user_id', as: 'friends' }); 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