Skip to content
Snippets Groups Projects

[#7] Friend 서비스 로직 개발

Merged 조대희 requested to merge feature/#7 into develop
1 file
+ 9
8
Compare changes
  • Side-by-side
  • Inline
+ 9
8
@@ -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
Loading