Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
W
WebBack
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
websystem
WebBack
Commits
110c8109
Commit
110c8109
authored
3 months ago
by
tpgus2603
Browse files
Options
Downloads
Patches
Plain Diff
refacotr: cascading 연관 관계 설정
parent
b124ee3c
No related branches found
Branches containing commit
No related tags found
1 merge request
!42
[#25] 배포코드 master브랜치로 이동
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
models/index.js
+95
-21
95 additions, 21 deletions
models/index.js
with
95 additions
and
21 deletions
models/index.js
+
95
−
21
View file @
110c8109
...
...
@@ -10,32 +10,106 @@ const Invite =require('./invite')
const
MeetingParticipant
=
require
(
'
./meetingParticipant
'
);
// const ChatRooms = require('./ChatRooms');
// 관계 설정
Friend
.
belongsTo
(
User
,
{
foreignKey
:
'
requester_id
'
,
as
:
'
requester
'
});
// 친구 요청을 보낸 사용자
Friend
.
belongsTo
(
User
,
{
foreignKey
:
'
receiver_id
'
,
as
:
'
receiver
'
});
// 친구 요청을 받은 사용자
// Friend 관계 설정
Friend
.
belongsTo
(
User
,
{
foreignKey
:
'
requester_id
'
,
as
:
'
requester
'
,
onDelete
:
'
CASCADE
'
,
});
Friend
.
belongsTo
(
User
,
{
foreignKey
:
'
receiver_id
'
,
as
:
'
receiver
'
,
onDelete
:
'
CASCADE
'
,
});
User
.
hasMany
(
Friend
,
{
foreignKey
:
'
requester_id
'
,
as
:
'
sentRequests
'
,
onDelete
:
'
CASCADE
'
,
});
User
.
hasMany
(
Friend
,
{
foreignKey
:
'
receiver_id
'
,
as
:
'
receivedRequests
'
,
onDelete
:
'
CASCADE
'
,
});
User
.
hasMany
(
Friend
,
{
foreignKey
:
'
requester_id
'
,
as
:
'
sentRequests
'
});
// 친구 요청을 보낸 목록
User
.
hasMany
(
Friend
,
{
foreignKey
:
'
receiver_id
'
,
as
:
'
receivedRequests
'
});
// 친구 요청을 받은 목록
// 연관 관계 설정
Meeting
.
belongsTo
(
User
,
{
foreignKey
:
'
created_by
'
,
as
:
'
creator
'
});
User
.
hasMany
(
Meeting
,
{
foreignKey
:
'
created_by
'
,
as
:
'
meetings
'
});
// Meeting 관계 설정
Meeting
.
belongsTo
(
User
,
{
foreignKey
:
'
created_by
'
,
as
:
'
creator
'
,
onDelete
:
'
SET NULL
'
,
// Meetings might persist even if the creator is deleted
});
User
.
hasMany
(
Meeting
,
{
foreignKey
:
'
created_by
'
,
as
:
'
meetings
'
,
onDelete
:
'
SET NULL
'
,
});
MeetingParticipant
.
belongsTo
(
Meeting
,
{
foreignKey
:
'
meeting_id
'
,
as
:
'
meeting
'
});
Meeting
.
hasMany
(
MeetingParticipant
,
{
foreignKey
:
'
meeting_id
'
,
as
:
'
participants
'
});
// MeetingParticipant 관계 설정
MeetingParticipant
.
belongsTo
(
Meeting
,
{
foreignKey
:
'
meeting_id
'
,
as
:
'
meeting
'
,
onDelete
:
'
CASCADE
'
,
});
Meeting
.
hasMany
(
MeetingParticipant
,
{
foreignKey
:
'
meeting_id
'
,
as
:
'
participants
'
,
onDelete
:
'
CASCADE
'
,
});
MeetingParticipant
.
belongsTo
(
User
,
{
foreignKey
:
'
user_id
'
,
as
:
'
user
'
,
onDelete
:
'
CASCADE
'
,
});
User
.
hasMany
(
MeetingParticipant
,
{
foreignKey
:
'
user_id
'
,
as
:
'
meetingParticipations
'
,
onDelete
:
'
CASCADE
'
,
});
MeetingParticipant
.
belongsTo
(
User
,
{
foreignKey
:
'
user_id
'
,
as
:
'
user
'
});
User
.
hasMany
(
MeetingParticipant
,
{
foreignKey
:
'
user_id
'
,
as
:
'
meetingParticipations
'
});
// Schedule 관계 설정
Schedule
.
belongsTo
(
User
,
{
foreignKey
:
'
user_id
'
,
as
:
'
user
'
,
onDelete
:
'
CASCADE
'
,
});
User
.
hasMany
(
Schedule
,
{
foreignKey
:
'
user_id
'
,
as
:
'
schedules
'
,
onDelete
:
'
CASCADE
'
,
});
Schedule
.
belongsTo
(
User
,
{
foreignKey
:
'
user_id
'
,
as
:
'
user
'
});
User
.
hasMany
(
Schedule
,
{
foreignKey
:
'
user_id
'
,
as
:
'
schedules
'
});
// Invite 관계 설정
Invite
.
belongsTo
(
Meeting
,
{
foreignKey
:
'
meeting_id
'
,
as
:
'
meeting
'
,
onDelete
:
'
CASCADE
'
,
});
Invite
.
belongsTo
(
User
,
{
foreignKey
:
'
inviter_id
'
,
as
:
'
inviter
'
,
onDelete
:
'
CASCADE
'
,
});
Invite
.
belongsTo
(
User
,
{
foreignKey
:
'
invitee_id
'
,
as
:
'
invitee
'
,
onDelete
:
'
CASCADE
'
,
});
User
.
hasMany
(
Invite
,
{
foreignKey
:
'
inviter_id
'
,
as
:
'
sentInvites
'
,
onDelete
:
'
CASCADE
'
,
});
User
.
hasMany
(
Invite
,
{
foreignKey
:
'
invitee_id
'
,
as
:
'
receivedInvites
'
,
onDelete
:
'
CASCADE
'
,
});
Meeting
.
hasMany
(
Invite
,
{
foreignKey
:
'
meeting_id
'
,
as
:
'
invites
'
,
onDelete
:
'
CASCADE
'
,
});
Invite
.
belongsTo
(
Meeting
,
{
foreignKey
:
'
meeting_id
'
,
as
:
'
meeting
'
});
Invite
.
belongsTo
(
User
,
{
foreignKey
:
'
inviter_id
'
,
as
:
'
inviter
'
});
// 초대한 사용자
Invite
.
belongsTo
(
User
,
{
foreignKey
:
'
invitee_id
'
,
as
:
'
invitee
'
});
// 초대받은 사용자
User
.
hasMany
(
Invite
,
{
foreignKey
:
'
inviter_id
'
,
as
:
'
sentInvites
'
});
// 보낸 초대 목록
User
.
hasMany
(
Invite
,
{
foreignKey
:
'
invitee_id
'
,
as
:
'
receivedInvites
'
});
// 받은 초대 목록
Meeting
.
hasMany
(
Invite
,
{
foreignKey
:
'
meeting_id
'
,
as
:
'
invites
'
});
// 해당 미팅의 모든 초대
module
.
exports
=
{
sequelize
,
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment