Some fixes and additions
This commit is contained in:
@@ -85,434 +85,437 @@ import PoliticalOffice from './falukant/data/political_office.js';
|
||||
import PoliticalOfficeBenefit from './falukant/predefine/political_office_benefit.js';
|
||||
import PoliticalOfficeBenefitType from './falukant/type/political_office_benefit_type.js';
|
||||
import PoliticalOfficeRequirement from './falukant/predefine/political_office_prerequisite.js';
|
||||
import PoliticalOfficePrerequisite from './falukant/predefine/political_office_prerequisite.js';
|
||||
import PoliticalOfficeHistory from './falukant/log/political_office_history.js';
|
||||
import ElectionHistory from './falukant/log/election_history.js';
|
||||
|
||||
export default function setupAssociations() {
|
||||
// UserParam related associations
|
||||
SettingsType.hasMany(UserParamType, { foreignKey: 'settingsId', as: 'user_param_types' });
|
||||
UserParamType.belongsTo(SettingsType, { foreignKey: 'settingsId', as: 'settings_type' });
|
||||
|
||||
UserParamType.hasMany(UserParam, { foreignKey: 'paramTypeId', as: 'user_params' });
|
||||
UserParam.belongsTo(UserParamType, { foreignKey: 'paramTypeId', as: 'paramType' });
|
||||
|
||||
User.hasMany(UserParam, { foreignKey: 'userId', as: 'user_params' });
|
||||
UserParam.belongsTo(User, { foreignKey: 'userId', as: 'user' });
|
||||
|
||||
UserParamValue.belongsTo(UserParamType, { foreignKey: 'userParamTypeId', as: 'user_param_value_type' });
|
||||
UserParamType.hasMany(UserParamValue, { foreignKey: 'userParamTypeId', as: 'user_param_type_value' });
|
||||
|
||||
UserRight.belongsTo(User, { foreignKey: 'userId', as: 'user_with_rights' });
|
||||
UserRight.belongsTo(UserRightType, { foreignKey: 'rightTypeId', as: 'rightType' });
|
||||
UserRightType.hasMany(UserRight, { foreignKey: 'rightTypeId', as: 'user_rights' });
|
||||
|
||||
UserParam.hasMany(UserParamVisibility, { foreignKey: 'param_id', as: 'param_visibilities' });
|
||||
UserParamVisibility.belongsTo(UserParam, { foreignKey: 'param_id', as: 'param' });
|
||||
|
||||
UserParamVisibility.belongsTo(UserParamVisibilityType, { foreignKey: 'visibility', as: 'visibility_type' });
|
||||
UserParamVisibilityType.hasMany(UserParamVisibility, { foreignKey: 'visibility', as: 'user_param_visibilities' });
|
||||
|
||||
// Interest related associations
|
||||
InterestType.hasMany(InterestTranslationType, { foreignKey: 'interestsId', as: 'interest_translations' });
|
||||
InterestTranslationType.belongsTo(InterestType, { foreignKey: 'interestsId', as: 'interest_translations' });
|
||||
|
||||
InterestType.hasMany(Interest, { foreignKey: 'userinterestId', as: 'user_interest_type' });
|
||||
User.hasMany(Interest, { foreignKey: 'userId', as: 'user_interests' });
|
||||
Interest.belongsTo(InterestType, { foreignKey: 'userinterestId', as: 'interest_type' });
|
||||
Interest.belongsTo(User, { foreignKey: 'userId', as: 'interest_owner' });
|
||||
|
||||
// Folder and Image related associations
|
||||
Folder.belongsTo(User, { foreignKey: 'userId' });
|
||||
User.hasMany(Folder, { foreignKey: 'userId' });
|
||||
|
||||
Folder.belongsTo(Folder, { foreignKey: 'parentId', as: 'parent' });
|
||||
Folder.hasMany(Folder, { foreignKey: 'parentId', as: 'children' });
|
||||
|
||||
Image.belongsTo(Folder, { foreignKey: 'folderId' });
|
||||
Folder.hasMany(Image, { foreignKey: 'folderId' });
|
||||
|
||||
Image.belongsTo(User, { foreignKey: 'userId' });
|
||||
User.hasMany(Image, { foreignKey: 'userId' });
|
||||
|
||||
// Image visibility associations
|
||||
Folder.belongsToMany(ImageVisibilityType, {
|
||||
through: FolderImageVisibility,
|
||||
foreignKey: 'folderId',
|
||||
otherKey: 'visibilityTypeId'
|
||||
});
|
||||
ImageVisibilityType.belongsToMany(Folder, {
|
||||
through: FolderImageVisibility,
|
||||
foreignKey: 'visibilityTypeId',
|
||||
otherKey: 'folderId'
|
||||
});
|
||||
|
||||
Image.belongsToMany(ImageVisibilityType, {
|
||||
through: ImageImageVisibility,
|
||||
foreignKey: 'imageId',
|
||||
otherKey: 'visibilityTypeId'
|
||||
});
|
||||
ImageVisibilityType.belongsToMany(Image, {
|
||||
through: ImageImageVisibility,
|
||||
foreignKey: 'visibilityTypeId',
|
||||
otherKey: 'imageId'
|
||||
});
|
||||
|
||||
Folder.belongsToMany(ImageVisibilityUser, {
|
||||
through: FolderVisibilityUser,
|
||||
foreignKey: 'folderId',
|
||||
otherKey: 'visibilityUserId'
|
||||
});
|
||||
ImageVisibilityUser.belongsToMany(Folder, {
|
||||
through: FolderVisibilityUser,
|
||||
foreignKey: 'visibilityUserId',
|
||||
otherKey: 'folderId'
|
||||
});
|
||||
// UserParam related associations
|
||||
SettingsType.hasMany(UserParamType, { foreignKey: 'settingsId', as: 'user_param_types' });
|
||||
UserParamType.belongsTo(SettingsType, { foreignKey: 'settingsId', as: 'settings_type' });
|
||||
|
||||
UserParamType.hasMany(UserParam, { foreignKey: 'paramTypeId', as: 'user_params' });
|
||||
UserParam.belongsTo(UserParamType, { foreignKey: 'paramTypeId', as: 'paramType' });
|
||||
|
||||
User.hasMany(UserParam, { foreignKey: 'userId', as: 'user_params' });
|
||||
UserParam.belongsTo(User, { foreignKey: 'userId', as: 'user' });
|
||||
|
||||
UserParamValue.belongsTo(UserParamType, { foreignKey: 'userParamTypeId', as: 'user_param_value_type' });
|
||||
UserParamType.hasMany(UserParamValue, { foreignKey: 'userParamTypeId', as: 'user_param_type_value' });
|
||||
|
||||
UserRight.belongsTo(User, { foreignKey: 'userId', as: 'user_with_rights' });
|
||||
UserRight.belongsTo(UserRightType, { foreignKey: 'rightTypeId', as: 'rightType' });
|
||||
UserRightType.hasMany(UserRight, { foreignKey: 'rightTypeId', as: 'user_rights' });
|
||||
|
||||
UserParam.hasMany(UserParamVisibility, { foreignKey: 'param_id', as: 'param_visibilities' });
|
||||
UserParamVisibility.belongsTo(UserParam, { foreignKey: 'param_id', as: 'param' });
|
||||
|
||||
UserParamVisibility.belongsTo(UserParamVisibilityType, { foreignKey: 'visibility', as: 'visibility_type' });
|
||||
UserParamVisibilityType.hasMany(UserParamVisibility, { foreignKey: 'visibility', as: 'user_param_visibilities' });
|
||||
|
||||
// Interest related associations
|
||||
InterestType.hasMany(InterestTranslationType, { foreignKey: 'interestsId', as: 'interest_translations' });
|
||||
InterestTranslationType.belongsTo(InterestType, { foreignKey: 'interestsId', as: 'interest_translations' });
|
||||
|
||||
InterestType.hasMany(Interest, { foreignKey: 'userinterestId', as: 'user_interest_type' });
|
||||
User.hasMany(Interest, { foreignKey: 'userId', as: 'user_interests' });
|
||||
Interest.belongsTo(InterestType, { foreignKey: 'userinterestId', as: 'interest_type' });
|
||||
Interest.belongsTo(User, { foreignKey: 'userId', as: 'interest_owner' });
|
||||
|
||||
// Folder and Image related associations
|
||||
Folder.belongsTo(User, { foreignKey: 'userId' });
|
||||
User.hasMany(Folder, { foreignKey: 'userId' });
|
||||
|
||||
Folder.belongsTo(Folder, { foreignKey: 'parentId', as: 'parent' });
|
||||
Folder.hasMany(Folder, { foreignKey: 'parentId', as: 'children' });
|
||||
|
||||
Image.belongsTo(Folder, { foreignKey: 'folderId' });
|
||||
Folder.hasMany(Image, { foreignKey: 'folderId' });
|
||||
|
||||
Image.belongsTo(User, { foreignKey: 'userId' });
|
||||
User.hasMany(Image, { foreignKey: 'userId' });
|
||||
|
||||
// Image visibility associations
|
||||
Folder.belongsToMany(ImageVisibilityType, {
|
||||
through: FolderImageVisibility,
|
||||
foreignKey: 'folderId',
|
||||
otherKey: 'visibilityTypeId'
|
||||
});
|
||||
ImageVisibilityType.belongsToMany(Folder, {
|
||||
through: FolderImageVisibility,
|
||||
foreignKey: 'visibilityTypeId',
|
||||
otherKey: 'folderId'
|
||||
});
|
||||
|
||||
Image.belongsToMany(ImageVisibilityType, {
|
||||
through: ImageImageVisibility,
|
||||
foreignKey: 'imageId',
|
||||
otherKey: 'visibilityTypeId'
|
||||
});
|
||||
ImageVisibilityType.belongsToMany(Image, {
|
||||
through: ImageImageVisibility,
|
||||
foreignKey: 'visibilityTypeId',
|
||||
otherKey: 'imageId'
|
||||
});
|
||||
|
||||
Folder.belongsToMany(ImageVisibilityUser, {
|
||||
through: FolderVisibilityUser,
|
||||
foreignKey: 'folderId',
|
||||
otherKey: 'visibilityUserId'
|
||||
});
|
||||
ImageVisibilityUser.belongsToMany(Folder, {
|
||||
through: FolderVisibilityUser,
|
||||
foreignKey: 'visibilityUserId',
|
||||
otherKey: 'folderId'
|
||||
});
|
||||
|
||||
// Guestbook related associations
|
||||
User.hasMany(GuestbookEntry, { foreignKey: 'recipientId', as: 'receivedEntries' });
|
||||
User.hasMany(GuestbookEntry, { foreignKey: 'senderId', as: 'sentEntries' });
|
||||
GuestbookEntry.belongsTo(User, { foreignKey: 'recipientId', as: 'recipient' });
|
||||
GuestbookEntry.belongsTo(User, { foreignKey: 'senderId', as: 'sender' });
|
||||
// Guestbook related associations
|
||||
User.hasMany(GuestbookEntry, { foreignKey: 'recipientId', as: 'receivedEntries' });
|
||||
User.hasMany(GuestbookEntry, { foreignKey: 'senderId', as: 'sentEntries' });
|
||||
GuestbookEntry.belongsTo(User, { foreignKey: 'recipientId', as: 'recipient' });
|
||||
GuestbookEntry.belongsTo(User, { foreignKey: 'senderId', as: 'sender' });
|
||||
|
||||
// Forum related associations
|
||||
Forum.hasMany(Title, { foreignKey: 'forumId' });
|
||||
Title.belongsTo(Forum, { foreignKey: 'forumId' });
|
||||
// Forum related associations
|
||||
Forum.hasMany(Title, { foreignKey: 'forumId' });
|
||||
Title.belongsTo(Forum, { foreignKey: 'forumId' });
|
||||
|
||||
Title.belongsTo(User, { foreignKey: 'createdBy', as: 'createdByUser' });
|
||||
User.hasMany(Title, { foreignKey: 'createdBy', as: 'titles' });
|
||||
Title.belongsTo(User, { foreignKey: 'createdBy', as: 'createdByUser' });
|
||||
User.hasMany(Title, { foreignKey: 'createdBy', as: 'titles' });
|
||||
|
||||
Title.hasMany(Message, { foreignKey: 'titleId', as: 'messages' });
|
||||
Message.belongsTo(Title, { foreignKey: 'titleId', as: 'title' });
|
||||
Title.hasMany(Message, { foreignKey: 'titleId', as: 'messages' });
|
||||
Message.belongsTo(Title, { foreignKey: 'titleId', as: 'title' });
|
||||
|
||||
Message.belongsTo(User, { foreignKey: 'createdBy', as: 'lastMessageUser' });
|
||||
User.hasMany(Message, { foreignKey: 'createdBy', as: 'userMessages' });
|
||||
Message.belongsTo(User, { foreignKey: 'createdBy', as: 'lastMessageUser' });
|
||||
User.hasMany(Message, { foreignKey: 'createdBy', as: 'userMessages' });
|
||||
|
||||
Message.hasMany(MessageImage, { foreignKey: 'messageId' });
|
||||
MessageImage.belongsTo(Message, { foreignKey: 'messageId' });
|
||||
Message.hasMany(MessageImage, { foreignKey: 'messageId' });
|
||||
MessageImage.belongsTo(Message, { foreignKey: 'messageId' });
|
||||
|
||||
Message.hasMany(MessageHistory, { foreignKey: 'messageId' });
|
||||
MessageHistory.belongsTo(Message, { foreignKey: 'messageId' });
|
||||
Message.hasMany(MessageHistory, { foreignKey: 'messageId' });
|
||||
MessageHistory.belongsTo(Message, { foreignKey: 'messageId' });
|
||||
|
||||
Title.hasMany(TitleHistory, { foreignKey: 'titleId' });
|
||||
TitleHistory.belongsTo(Title, { foreignKey: 'titleId' });
|
||||
Title.hasMany(TitleHistory, { foreignKey: 'titleId' });
|
||||
TitleHistory.belongsTo(Title, { foreignKey: 'titleId' });
|
||||
|
||||
// Forum permissions associations
|
||||
Forum.hasMany(ForumUserPermission, { foreignKey: 'forumId', as: 'userPermissions' });
|
||||
ForumUserPermission.belongsTo(Forum, { foreignKey: 'forumId' });
|
||||
// Forum permissions associations
|
||||
Forum.hasMany(ForumUserPermission, { foreignKey: 'forumId', as: 'userPermissions' });
|
||||
ForumUserPermission.belongsTo(Forum, { foreignKey: 'forumId' });
|
||||
|
||||
User.hasMany(ForumUserPermission, { foreignKey: 'userId', as: 'userPermissions' });
|
||||
ForumUserPermission.belongsTo(User, { foreignKey: 'userId' });
|
||||
User.hasMany(ForumUserPermission, { foreignKey: 'userId', as: 'userPermissions' });
|
||||
ForumUserPermission.belongsTo(User, { foreignKey: 'userId' });
|
||||
|
||||
Forum.belongsToMany(ForumPermission, {
|
||||
through: ForumForumPermission,
|
||||
foreignKey: 'forumId',
|
||||
as: 'associatedPermissions'
|
||||
});
|
||||
Forum.belongsToMany(ForumPermission, {
|
||||
through: ForumForumPermission,
|
||||
foreignKey: 'forumId',
|
||||
as: 'associatedPermissions'
|
||||
});
|
||||
|
||||
ForumPermission.belongsToMany(Forum, {
|
||||
through: ForumForumPermission,
|
||||
foreignKey: 'permissionId',
|
||||
as: 'forums'
|
||||
});
|
||||
ForumPermission.belongsToMany(Forum, {
|
||||
through: ForumForumPermission,
|
||||
foreignKey: 'permissionId',
|
||||
as: 'forums'
|
||||
});
|
||||
|
||||
ForumPermission.hasMany(ForumUserPermission, { foreignKey: 'permissionId' });
|
||||
ForumUserPermission.belongsTo(ForumPermission, { foreignKey: 'permissionId' });
|
||||
ForumPermission.hasMany(ForumUserPermission, { foreignKey: 'permissionId' });
|
||||
ForumUserPermission.belongsTo(ForumPermission, { foreignKey: 'permissionId' });
|
||||
|
||||
Friendship.belongsTo(User, { foreignKey: 'user1Id', as: 'friendSender' });
|
||||
Friendship.belongsTo(User, { foreignKey: 'user2Id', as: 'friendReceiver' });
|
||||
User.hasMany(Friendship, { foreignKey: 'user1Id', as: 'friendSender' });
|
||||
User.hasMany(Friendship, { foreignKey: 'user2Id', as: 'friendReceiver' });
|
||||
Friendship.belongsTo(User, { foreignKey: 'user1Id', as: 'friendSender' });
|
||||
Friendship.belongsTo(User, { foreignKey: 'user2Id', as: 'friendReceiver' });
|
||||
User.hasMany(Friendship, { foreignKey: 'user1Id', as: 'friendSender' });
|
||||
User.hasMany(Friendship, { foreignKey: 'user2Id', as: 'friendReceiver' });
|
||||
|
||||
User.hasMany(FalukantUser, { foreignKey: 'userId', as: 'falukantData' });
|
||||
FalukantUser.belongsTo(User, { foreignKey: 'userId', as: 'user' });
|
||||
User.hasMany(FalukantUser, { foreignKey: 'userId', as: 'falukantData' });
|
||||
FalukantUser.belongsTo(User, { foreignKey: 'userId', as: 'user' });
|
||||
|
||||
RegionType.hasMany(RegionType, { foreignKey: 'parentId', as: 'children' });
|
||||
RegionType.belongsTo(RegionType, { foreignKey: 'parentId', as: 'parent' });
|
||||
RegionType.hasMany(RegionType, { foreignKey: 'parentId', as: 'children' });
|
||||
RegionType.belongsTo(RegionType, { foreignKey: 'parentId', as: 'parent' });
|
||||
|
||||
RegionData.hasMany(RegionData, { foreignKey: 'parentId', as: 'children' });
|
||||
RegionData.belongsTo(RegionData, { foreignKey: 'parentId', as: 'parent' });
|
||||
RegionData.hasMany(RegionData, { foreignKey: 'parentId', as: 'children' });
|
||||
RegionData.belongsTo(RegionData, { foreignKey: 'parentId', as: 'parent' });
|
||||
|
||||
RegionData.belongsTo(RegionType, { foreignKey: 'regionTypeId', as: 'regionType' });
|
||||
RegionType.hasMany(RegionData, { foreignKey: 'regionTypeId', as: 'regions' });
|
||||
RegionData.belongsTo(RegionType, { foreignKey: 'regionTypeId', as: 'regionType' });
|
||||
RegionType.hasMany(RegionData, { foreignKey: 'regionTypeId', as: 'regions' });
|
||||
|
||||
FalukantUser.belongsTo(RegionData, { foreignKey: 'mainBranchRegionId', as: 'mainBranchRegion' });
|
||||
RegionData.hasMany(FalukantUser, { foreignKey: 'mainBranchRegionId', as: 'users' });
|
||||
FalukantUser.belongsTo(RegionData, { foreignKey: 'mainBranchRegionId', as: 'mainBranchRegion' });
|
||||
RegionData.hasMany(FalukantUser, { foreignKey: 'mainBranchRegionId', as: 'users' });
|
||||
|
||||
FalukantCharacter.belongsTo(FalukantUser, { foreignKey: 'userId', as: 'user' });
|
||||
FalukantUser.hasOne(FalukantCharacter, { foreignKey: 'userId', as: 'character' });
|
||||
FalukantCharacter.belongsTo(FalukantUser, { foreignKey: 'userId', as: 'user' });
|
||||
FalukantUser.hasOne(FalukantCharacter, { foreignKey: 'userId', as: 'character' });
|
||||
|
||||
FalukantCharacter.belongsTo(FalukantPredefineFirstname, { foreignKey: 'firstName', as: 'definedFirstName' });
|
||||
FalukantPredefineFirstname.hasMany(FalukantCharacter, { foreignKey: 'firstName', as: 'charactersWithFirstName' });
|
||||
FalukantCharacter.belongsTo(FalukantPredefineFirstname, { foreignKey: 'firstName', as: 'definedFirstName' });
|
||||
FalukantPredefineFirstname.hasMany(FalukantCharacter, { foreignKey: 'firstName', as: 'charactersWithFirstName' });
|
||||
|
||||
FalukantCharacter.belongsTo(FalukantPredefineLastname, { foreignKey: 'lastName', as: 'definedLastName' });
|
||||
FalukantPredefineLastname.hasMany(FalukantCharacter, { foreignKey: 'lastName', as: 'charactersWithLastName' });
|
||||
FalukantCharacter.belongsTo(FalukantPredefineLastname, { foreignKey: 'lastName', as: 'definedLastName' });
|
||||
FalukantPredefineLastname.hasMany(FalukantCharacter, { foreignKey: 'lastName', as: 'charactersWithLastName' });
|
||||
|
||||
FalukantCharacter.belongsTo(TitleOfNobility, { foreignKey: 'titleOfNobility', as: 'nobleTitle' });
|
||||
TitleOfNobility.hasMany(FalukantCharacter, { foreignKey: 'titleOfNobility', as: 'charactersWithNobleTitle' });
|
||||
FalukantCharacter.belongsTo(TitleOfNobility, { foreignKey: 'titleOfNobility', as: 'nobleTitle' });
|
||||
TitleOfNobility.hasMany(FalukantCharacter, { foreignKey: 'titleOfNobility', as: 'charactersWithNobleTitle' });
|
||||
|
||||
FalukantCharacter.belongsTo(RegionData, { foreignKey: 'regionId', as: 'region' });
|
||||
RegionData.hasMany(FalukantCharacter, { foreignKey: 'regionId', as: 'charactersInRegion' });
|
||||
FalukantCharacter.belongsTo(RegionData, { foreignKey: 'regionId', as: 'region' });
|
||||
RegionData.hasMany(FalukantCharacter, { foreignKey: 'regionId', as: 'charactersInRegion' });
|
||||
|
||||
FalukantStock.belongsTo(FalukantStockType, { foreignKey: 'stockTypeId', as: 'stockType' });
|
||||
FalukantStockType.hasMany(FalukantStock, { foreignKey: 'stockTypeId', as: 'stocks' });
|
||||
FalukantStock.belongsTo(FalukantStockType, { foreignKey: 'stockTypeId', as: 'stockType' });
|
||||
FalukantStockType.hasMany(FalukantStock, { foreignKey: 'stockTypeId', as: 'stocks' });
|
||||
|
||||
Knowledge.belongsTo(ProductType, { foreignKey: 'productId', as: 'productType' });
|
||||
ProductType.hasMany(Knowledge, { foreignKey: 'productId', as: 'knowledges' });
|
||||
Knowledge.belongsTo(ProductType, { foreignKey: 'productId', as: 'productType' });
|
||||
ProductType.hasMany(Knowledge, { foreignKey: 'productId', as: 'knowledges' });
|
||||
|
||||
Knowledge.belongsTo(FalukantCharacter, { foreignKey: 'characterId', as: 'character' });
|
||||
FalukantCharacter.hasMany(Knowledge, { foreignKey: 'characterId', as: 'knowledges' });
|
||||
Knowledge.belongsTo(FalukantCharacter, { foreignKey: 'characterId', as: 'character' });
|
||||
FalukantCharacter.hasMany(Knowledge, { foreignKey: 'characterId', as: 'knowledges' });
|
||||
|
||||
TitleRequirement.belongsTo(TitleOfNobility, { foreignKey: 'titleId', as: 'title' });
|
||||
TitleOfNobility.hasMany(TitleRequirement, { foreignKey: 'titleId', as: 'requirements' });
|
||||
TitleRequirement.belongsTo(TitleOfNobility, { foreignKey: 'titleId', as: 'title' });
|
||||
TitleOfNobility.hasMany(TitleRequirement, { foreignKey: 'titleId', as: 'requirements' });
|
||||
|
||||
Branch.belongsTo(RegionData, { foreignKey: 'regionId', as: 'region' });
|
||||
RegionData.hasMany(Branch, { foreignKey: 'regionId', as: 'branches' });
|
||||
Branch.belongsTo(RegionData, { foreignKey: 'regionId', as: 'region' });
|
||||
RegionData.hasMany(Branch, { foreignKey: 'regionId', as: 'branches' });
|
||||
|
||||
Branch.belongsTo(FalukantUser, { foreignKey: 'falukantUserId', as: 'user' });
|
||||
FalukantUser.hasMany(Branch, { foreignKey: 'falukantUserId', as: 'branches' });
|
||||
Branch.belongsTo(FalukantUser, { foreignKey: 'falukantUserId', as: 'user' });
|
||||
FalukantUser.hasMany(Branch, { foreignKey: 'falukantUserId', as: 'branches' });
|
||||
|
||||
Branch.belongsTo(BranchType, { foreignKey: 'branchTypeId', as: 'branchType' });
|
||||
BranchType.hasMany(Branch, { foreignKey: 'branchTypeId', as: 'branches' });
|
||||
Branch.belongsTo(BranchType, { foreignKey: 'branchTypeId', as: 'branchType' });
|
||||
BranchType.hasMany(Branch, { foreignKey: 'branchTypeId', as: 'branches' });
|
||||
|
||||
Production.belongsTo(Branch, { foreignKey: 'branchId', as: 'branch' });
|
||||
Branch.hasMany(Production, { foreignKey: 'branchId', as: 'productions' });
|
||||
Production.belongsTo(Branch, { foreignKey: 'branchId', as: 'branch' });
|
||||
Branch.hasMany(Production, { foreignKey: 'branchId', as: 'productions' });
|
||||
|
||||
Production.belongsTo(ProductType, { foreignKey: 'productId', as: 'productType' });
|
||||
ProductType.hasMany(Production, { foreignKey: 'productId', as: 'productions' });
|
||||
Production.belongsTo(ProductType, { foreignKey: 'productId', as: 'productType' });
|
||||
ProductType.hasMany(Production, { foreignKey: 'productId', as: 'productions' });
|
||||
|
||||
Inventory.belongsTo(FalukantStock, { foreignKey: 'stockId', as: 'stock' });
|
||||
FalukantStock.hasMany(Inventory, { foreignKey: 'stockId', as: 'inventories' });
|
||||
Inventory.belongsTo(FalukantStock, { foreignKey: 'stockId', as: 'stock' });
|
||||
FalukantStock.hasMany(Inventory, { foreignKey: 'stockId', as: 'inventories' });
|
||||
|
||||
Inventory.belongsTo(ProductType, { foreignKey: 'productId', as: 'productType' });
|
||||
ProductType.hasMany(Inventory, { foreignKey: 'productId', as: 'inventories' });
|
||||
Inventory.belongsTo(ProductType, { foreignKey: 'productId', as: 'productType' });
|
||||
ProductType.hasMany(Inventory, { foreignKey: 'productId', as: 'inventories' });
|
||||
|
||||
BuyableStock.belongsTo(RegionData, { foreignKey: 'regionId', as: 'region' });
|
||||
RegionData.hasMany(BuyableStock, { foreignKey: 'regionId', as: 'buyableStocks' });
|
||||
BuyableStock.belongsTo(RegionData, { foreignKey: 'regionId', as: 'region' });
|
||||
RegionData.hasMany(BuyableStock, { foreignKey: 'regionId', as: 'buyableStocks' });
|
||||
|
||||
Branch.hasMany(FalukantStock, { foreignKey: 'branchId', as: 'stocks' });
|
||||
FalukantStock.belongsTo(Branch, { foreignKey: 'branchId', as: 'branch' });
|
||||
Branch.hasMany(FalukantStock, { foreignKey: 'branchId', as: 'stocks' });
|
||||
FalukantStock.belongsTo(Branch, { foreignKey: 'branchId', as: 'branch' });
|
||||
|
||||
MoneyFlow.belongsTo(FalukantUser, { foreignKey: 'falukantUserId', as: 'user' });
|
||||
FalukantUser.hasMany(MoneyFlow, { foreignKey: 'falukantUserId', as: 'flows' });
|
||||
MoneyFlow.belongsTo(FalukantUser, { foreignKey: 'falukantUserId', as: 'user' });
|
||||
FalukantUser.hasMany(MoneyFlow, { foreignKey: 'falukantUserId', as: 'flows' });
|
||||
|
||||
BuyableStock.belongsTo(FalukantStockType, { foreignKey: 'stockTypeId', as: 'stockType' });
|
||||
FalukantStockType.hasMany(BuyableStock, { foreignKey: 'stockTypeId', as: 'buyableStocks' });
|
||||
BuyableStock.belongsTo(FalukantStockType, { foreignKey: 'stockTypeId', as: 'stockType' });
|
||||
FalukantStockType.hasMany(BuyableStock, { foreignKey: 'stockTypeId', as: 'buyableStocks' });
|
||||
|
||||
Director.belongsTo(FalukantUser, { foreignKey: 'employerUserId', as: 'user' });
|
||||
FalukantUser.hasMany(Director, { foreignKey: 'employerUserId', as: 'directors' });
|
||||
Director.belongsTo(FalukantUser, { foreignKey: 'employerUserId', as: 'user' });
|
||||
FalukantUser.hasMany(Director, { foreignKey: 'employerUserId', as: 'directors' });
|
||||
|
||||
Director.belongsTo(FalukantCharacter, { foreignKey: 'directorCharacterId', as: 'character' });
|
||||
FalukantCharacter.hasMany(Director, { foreignKey: 'directorCharacterId', as: 'directors' });
|
||||
Director.belongsTo(FalukantCharacter, { foreignKey: 'directorCharacterId', as: 'character' });
|
||||
FalukantCharacter.hasMany(Director, { foreignKey: 'directorCharacterId', as: 'directors' });
|
||||
|
||||
DirectorProposal.belongsTo(FalukantUser, { foreignKey: 'employerUserId', as: 'user' });
|
||||
FalukantUser.hasMany(DirectorProposal, { foreignKey: 'employerUserId', as: 'directorProposals' });
|
||||
DirectorProposal.belongsTo(FalukantUser, { foreignKey: 'employerUserId', as: 'user' });
|
||||
FalukantUser.hasMany(DirectorProposal, { foreignKey: 'employerUserId', as: 'directorProposals' });
|
||||
|
||||
DirectorProposal.belongsTo(FalukantCharacter, { foreignKey: 'directorCharacterId', as: 'character' });
|
||||
FalukantCharacter.hasMany(DirectorProposal, { foreignKey: 'directorCharacterId', as: 'directorProposals' });
|
||||
DirectorProposal.belongsTo(FalukantCharacter, { foreignKey: 'directorCharacterId', as: 'character' });
|
||||
FalukantCharacter.hasMany(DirectorProposal, { foreignKey: 'directorCharacterId', as: 'directorProposals' });
|
||||
|
||||
TownProductWorth.belongsTo(ProductType, { foreignKey: 'productId', as: 'productType' });
|
||||
ProductType.hasMany(TownProductWorth, { foreignKey: 'productId', as: 'townProductWorths' });
|
||||
TownProductWorth.belongsTo(ProductType, { foreignKey: 'productId', as: 'productType' });
|
||||
ProductType.hasMany(TownProductWorth, { foreignKey: 'productId', as: 'townProductWorths' });
|
||||
|
||||
TownProductWorth.belongsTo(RegionData, { foreignKey: 'regionId', as: 'region' });
|
||||
RegionData.hasMany(TownProductWorth, { foreignKey: 'regionId', as: 'townProductWorths' });
|
||||
TownProductWorth.belongsTo(RegionData, { foreignKey: 'regionId', as: 'region' });
|
||||
RegionData.hasMany(TownProductWorth, { foreignKey: 'regionId', as: 'townProductWorths' });
|
||||
|
||||
DayProduction.belongsTo(ProductType, { foreignKey: 'productId', as: 'productType' });
|
||||
ProductType.hasMany(DayProduction, { foreignKey: 'productId', as: 'dayProductions' });
|
||||
DayProduction.belongsTo(ProductType, { foreignKey: 'productId', as: 'productType' });
|
||||
ProductType.hasMany(DayProduction, { foreignKey: 'productId', as: 'dayProductions' });
|
||||
|
||||
DayProduction.belongsTo(RegionData, { foreignKey: 'regionId', as: 'region' });
|
||||
RegionData.hasMany(DayProduction, { foreignKey: 'regionId', as: 'dayProductions' });
|
||||
DayProduction.belongsTo(RegionData, { foreignKey: 'regionId', as: 'region' });
|
||||
RegionData.hasMany(DayProduction, { foreignKey: 'regionId', as: 'dayProductions' });
|
||||
|
||||
DayProduction.belongsTo(FalukantUser, { foreignKey: 'producerId', as: 'user' });
|
||||
FalukantUser.hasMany(DayProduction, { foreignKey: 'producerId', as: 'dayProductions' });
|
||||
DayProduction.belongsTo(FalukantUser, { foreignKey: 'producerId', as: 'user' });
|
||||
FalukantUser.hasMany(DayProduction, { foreignKey: 'producerId', as: 'dayProductions' });
|
||||
|
||||
DaySell.belongsTo(ProductType, { foreignKey: 'productId', as: 'productType' });
|
||||
ProductType.hasMany(DaySell, { foreignKey: 'productId', as: 'daySells' });
|
||||
DaySell.belongsTo(ProductType, { foreignKey: 'productId', as: 'productType' });
|
||||
ProductType.hasMany(DaySell, { foreignKey: 'productId', as: 'daySells' });
|
||||
|
||||
DaySell.belongsTo(RegionData, { foreignKey: 'regionId', as: 'region' });
|
||||
RegionData.hasMany(DaySell, { foreignKey: 'regionId', as: 'daySells' });
|
||||
DaySell.belongsTo(RegionData, { foreignKey: 'regionId', as: 'region' });
|
||||
RegionData.hasMany(DaySell, { foreignKey: 'regionId', as: 'daySells' });
|
||||
|
||||
DaySell.belongsTo(FalukantUser, { foreignKey: 'sellerId', as: 'user' });
|
||||
FalukantUser.hasMany(DaySell, { foreignKey: 'sellerId', as: 'daySells' });
|
||||
DaySell.belongsTo(FalukantUser, { foreignKey: 'sellerId', as: 'user' });
|
||||
FalukantUser.hasMany(DaySell, { foreignKey: 'sellerId', as: 'daySells' });
|
||||
|
||||
Notification.belongsTo(FalukantUser, { foreignKey: 'userId', as: 'user' });
|
||||
FalukantUser.hasMany(Notification, { foreignKey: 'userId', as: 'notifications' });
|
||||
Notification.belongsTo(FalukantUser, { foreignKey: 'userId', as: 'user' });
|
||||
FalukantUser.hasMany(Notification, { foreignKey: 'userId', as: 'notifications' });
|
||||
|
||||
MarriageProposal.belongsTo(FalukantCharacter, { foreignKey: 'requesterCharacterId', as: 'requesterCharacter', });
|
||||
FalukantCharacter.hasMany(MarriageProposal, { foreignKey: 'requesterCharacterId', as: 'initiatedProposals' });
|
||||
MarriageProposal.belongsTo(FalukantCharacter, { foreignKey: 'requesterCharacterId', as: 'requesterCharacter', });
|
||||
FalukantCharacter.hasMany(MarriageProposal, { foreignKey: 'requesterCharacterId', as: 'initiatedProposals' });
|
||||
|
||||
MarriageProposal.belongsTo(FalukantCharacter, { foreignKey: 'proposedCharacterId', as: 'proposedCharacter', });
|
||||
FalukantCharacter.hasMany(MarriageProposal, { foreignKey: 'proposedCharacterId', as: 'receivedProposals' });
|
||||
MarriageProposal.belongsTo(FalukantCharacter, { foreignKey: 'proposedCharacterId', as: 'proposedCharacter', });
|
||||
FalukantCharacter.hasMany(MarriageProposal, { foreignKey: 'proposedCharacterId', as: 'receivedProposals' });
|
||||
|
||||
FalukantCharacter.belongsToMany(CharacterTrait, { through: FalukantCharacterTrait, foreignKey: 'character_id', as: 'traits', });
|
||||
CharacterTrait.belongsToMany(FalukantCharacter, { through: FalukantCharacterTrait, foreignKey: 'trait_id', as: 'characters', });
|
||||
FalukantCharacter.belongsToMany(CharacterTrait, { through: FalukantCharacterTrait, foreignKey: 'character_id', as: 'traits', });
|
||||
CharacterTrait.belongsToMany(FalukantCharacter, { through: FalukantCharacterTrait, foreignKey: 'trait_id', as: 'characters', });
|
||||
|
||||
Mood.hasMany(FalukantCharacter, { foreignKey: 'mood_id', as: 'moods' });
|
||||
FalukantCharacter.belongsTo(Mood, { foreignKey: 'mood_id', as: 'mood' });
|
||||
Mood.hasMany(FalukantCharacter, { foreignKey: 'mood_id', as: 'moods' });
|
||||
FalukantCharacter.belongsTo(Mood, { foreignKey: 'mood_id', as: 'mood' });
|
||||
|
||||
PromotionalGift.belongsToMany(CharacterTrait, { through: PromotionalGiftCharacterTrait, foreignKey: 'gift_id', as: 'traits', });
|
||||
CharacterTrait.belongsToMany(PromotionalGift, { through: PromotionalGiftCharacterTrait, foreignKey: 'trait_id', as: 'gifts', });
|
||||
PromotionalGift.belongsToMany(CharacterTrait, { through: PromotionalGiftCharacterTrait, foreignKey: 'gift_id', as: 'traits', });
|
||||
CharacterTrait.belongsToMany(PromotionalGift, { through: PromotionalGiftCharacterTrait, foreignKey: 'trait_id', as: 'gifts', });
|
||||
|
||||
PromotionalGift.belongsToMany(Mood, { through: PromotionalGiftMood, foreignKey: 'gift_id', as: 'moods', });
|
||||
Mood.belongsToMany(PromotionalGift, { through: PromotionalGiftMood, foreignKey: 'mood_id', as: 'gifts', });
|
||||
PromotionalGift.belongsToMany(Mood, { through: PromotionalGiftMood, foreignKey: 'gift_id', as: 'moods', });
|
||||
Mood.belongsToMany(PromotionalGift, { through: PromotionalGiftMood, foreignKey: 'mood_id', as: 'gifts', });
|
||||
|
||||
Relationship.belongsTo(RelationshipType, { foreignKey: 'relationshipTypeId', as: 'relationshipType' });
|
||||
RelationshipType.hasMany(Relationship, { foreignKey: 'relationshipTypeId', as: 'relationships' });
|
||||
Relationship.belongsTo(RelationshipType, { foreignKey: 'relationshipTypeId', as: 'relationshipType' });
|
||||
RelationshipType.hasMany(Relationship, { foreignKey: 'relationshipTypeId', as: 'relationships' });
|
||||
|
||||
Relationship.belongsTo(FalukantCharacter, { foreignKey: 'character1Id', as: 'character1', });
|
||||
Relationship.belongsTo(FalukantCharacter, { foreignKey: 'character2Id', as: 'character2', });
|
||||
FalukantCharacter.hasMany(Relationship, { foreignKey: 'character1Id', as: 'relationshipsAsCharacter1', });
|
||||
FalukantCharacter.hasMany(Relationship, { foreignKey: 'character2Id', as: 'relationshipsAsCharacter2', });
|
||||
Relationship.belongsTo(FalukantCharacter, { foreignKey: 'character1Id', as: 'character1', });
|
||||
Relationship.belongsTo(FalukantCharacter, { foreignKey: 'character2Id', as: 'character2', });
|
||||
FalukantCharacter.hasMany(Relationship, { foreignKey: 'character1Id', as: 'relationshipsAsCharacter1', });
|
||||
FalukantCharacter.hasMany(Relationship, { foreignKey: 'character2Id', as: 'relationshipsAsCharacter2', });
|
||||
|
||||
PromotionalGiftLog.belongsTo(PromotionalGift, { foreignKey: 'giftId', as: 'gift' });
|
||||
PromotionalGift.hasMany(PromotionalGiftLog, { foreignKey: 'giftId', as: 'logs' });
|
||||
PromotionalGiftLog.belongsTo(PromotionalGift, { foreignKey: 'giftId', as: 'gift' });
|
||||
PromotionalGift.hasMany(PromotionalGiftLog, { foreignKey: 'giftId', as: 'logs' });
|
||||
|
||||
PromotionalGiftLog.belongsTo(FalukantCharacter, { foreignKey: 'senderCharacterId', as: 'character' });
|
||||
FalukantCharacter.hasMany(PromotionalGiftLog, { foreignKey: 'senderCharacterId', as: 'logs' });
|
||||
PromotionalGiftLog.belongsTo(FalukantCharacter, { foreignKey: 'senderCharacterId', as: 'character' });
|
||||
FalukantCharacter.hasMany(PromotionalGiftLog, { foreignKey: 'senderCharacterId', as: 'logs' });
|
||||
|
||||
PromotionalGiftLog.belongsTo(FalukantCharacter, { foreignKey: 'recipientCharacterId', as: 'recipient' });
|
||||
FalukantCharacter.hasMany(PromotionalGiftLog, { foreignKey: 'recipientCharacterId', as: 'giftlogs' });
|
||||
PromotionalGiftLog.belongsTo(FalukantCharacter, { foreignKey: 'recipientCharacterId', as: 'recipient' });
|
||||
FalukantCharacter.hasMany(PromotionalGiftLog, { foreignKey: 'recipientCharacterId', as: 'giftlogs' });
|
||||
|
||||
PromotionalGift.hasMany(PromotionalGiftCharacterTrait, { foreignKey: 'gift_id', as: 'characterTraits' });
|
||||
PromotionalGift.hasMany(PromotionalGiftMood, { foreignKey: 'gift_id', as: 'promotionalgiftmoods' });
|
||||
PromotionalGift.hasMany(PromotionalGiftCharacterTrait, { foreignKey: 'gift_id', as: 'characterTraits' });
|
||||
PromotionalGift.hasMany(PromotionalGiftMood, { foreignKey: 'gift_id', as: 'promotionalgiftmoods' });
|
||||
|
||||
PromotionalGiftCharacterTrait.belongsTo(PromotionalGift, { foreignKey: 'gift_id', as: 'promotionalgiftcharactertrait' });
|
||||
PromotionalGiftMood.belongsTo(PromotionalGift, { foreignKey: 'gift_id', as: 'promotionalgiftcharactermood' });
|
||||
PromotionalGiftCharacterTrait.belongsTo(PromotionalGift, { foreignKey: 'gift_id', as: 'promotionalgiftcharactertrait' });
|
||||
PromotionalGiftMood.belongsTo(PromotionalGift, { foreignKey: 'gift_id', as: 'promotionalgiftcharactermood' });
|
||||
|
||||
HouseType.hasMany(BuyableHouse, { foreignKey: 'houseTypeId', as: 'buyableHouses' });
|
||||
BuyableHouse.belongsTo(HouseType, { foreignKey: 'houseTypeId', as: 'houseType' });
|
||||
HouseType.hasMany(BuyableHouse, { foreignKey: 'houseTypeId', as: 'buyableHouses' });
|
||||
BuyableHouse.belongsTo(HouseType, { foreignKey: 'houseTypeId', as: 'houseType' });
|
||||
|
||||
HouseType.hasMany(UserHouse, { foreignKey: 'houseTypeId', as: 'userHouses' });
|
||||
UserHouse.belongsTo(HouseType, { foreignKey: 'houseTypeId', as: 'houseType' });
|
||||
HouseType.hasMany(UserHouse, { foreignKey: 'houseTypeId', as: 'userHouses' });
|
||||
UserHouse.belongsTo(HouseType, { foreignKey: 'houseTypeId', as: 'houseType' });
|
||||
|
||||
FalukantUser.hasOne(UserHouse, { foreignKey: 'userId', as: 'userHouse' });
|
||||
UserHouse.belongsTo(FalukantUser, { foreignKey: 'userId', as: 'houseUser' });
|
||||
FalukantUser.hasOne(UserHouse, { foreignKey: 'userId', as: 'userHouse' });
|
||||
UserHouse.belongsTo(FalukantUser, { foreignKey: 'userId', as: 'houseUser' });
|
||||
|
||||
TitleOfNobility.hasMany(HouseType, { foreignKey: 'minimumNobleTitle', as: 'houseTypes' });
|
||||
HouseType.belongsTo(TitleOfNobility, { foreignKey: 'minimumNobleTitle', as: 'titleOfNobility' });
|
||||
|
||||
PartyType.hasMany(Party, { foreignKey: 'partyTypeId', as: 'parties' });
|
||||
Party.belongsTo(PartyType, { foreignKey: 'partyTypeId', as: 'partyType' });
|
||||
|
||||
MusicType.hasMany(Party, { foreignKey: 'musicTypeId', as: 'parties' });
|
||||
Party.belongsTo(MusicType, { foreignKey: 'musicTypeId', as: 'musicType' });
|
||||
|
||||
BanquetteType.hasMany(Party, { foreignKey: 'banquetteTypeId', as: 'parties' });
|
||||
Party.belongsTo(BanquetteType, { foreignKey: 'banquetteTypeId', as: 'banquetteType' });
|
||||
|
||||
FalukantUser.hasMany(Party, { foreignKey: 'falukantUserId', as: 'parties' });
|
||||
Party.belongsTo(FalukantUser, { foreignKey: 'falukantUserId', as: 'partyUser' });
|
||||
|
||||
Party.belongsToMany(TitleOfNobility, {
|
||||
through: PartyInvitedNobility,
|
||||
foreignKey: 'party_id',
|
||||
otherKey: 'title_of_nobility_id',
|
||||
as: 'invitedNobilities',
|
||||
});
|
||||
TitleOfNobility.belongsToMany(Party, {
|
||||
through: PartyInvitedNobility,
|
||||
foreignKey: 'title_of_nobility_id',
|
||||
otherKey: 'party_id',
|
||||
as: 'partiesInvitedTo',
|
||||
});
|
||||
|
||||
ChildRelation.belongsTo(FalukantCharacter, {
|
||||
foreignKey: 'fatherCharacterId',
|
||||
as: 'father'
|
||||
});
|
||||
FalukantCharacter.hasMany(ChildRelation, {
|
||||
foreignKey: 'fatherCharacterId',
|
||||
as: 'childrenFather'
|
||||
});
|
||||
|
||||
ChildRelation.belongsTo(FalukantCharacter, {
|
||||
foreignKey: 'motherCharacterId',
|
||||
as: 'mother'
|
||||
});
|
||||
FalukantCharacter.hasMany(ChildRelation, {
|
||||
foreignKey: 'motherCharacterId',
|
||||
as: 'childrenMother'
|
||||
});
|
||||
|
||||
ChildRelation.belongsTo(FalukantCharacter, {
|
||||
foreignKey: 'childCharacterId',
|
||||
as: 'child'
|
||||
});
|
||||
FalukantCharacter.hasMany(ChildRelation, {
|
||||
foreignKey: 'childCharacterId',
|
||||
as: 'parentRelations'
|
||||
});
|
||||
|
||||
Learning.belongsTo(LearnRecipient, {
|
||||
foreignKey: 'learningRecipientId',
|
||||
as: 'recipient'
|
||||
}
|
||||
);
|
||||
|
||||
LearnRecipient.hasMany(Learning, {
|
||||
foreignKey: 'learningRecipientId',
|
||||
as: 'learnings'
|
||||
});
|
||||
|
||||
Learning.belongsTo(FalukantUser, {
|
||||
foreignKey: 'associatedFalukantUserId',
|
||||
as: 'learner'
|
||||
}
|
||||
);
|
||||
|
||||
FalukantUser.hasMany(Learning, {
|
||||
foreignKey: 'associatedFalukantUserId',
|
||||
as: 'learnings'
|
||||
});
|
||||
|
||||
Learning.belongsTo(ProductType, {
|
||||
foreignKey: 'productId',
|
||||
as: 'productType'
|
||||
});
|
||||
|
||||
ProductType.hasMany(Learning, {
|
||||
foreignKey: 'productId',
|
||||
as: 'learnings'
|
||||
});
|
||||
|
||||
Learning.belongsTo(FalukantCharacter, {
|
||||
foreignKey: 'associatedLearningCharacterId',
|
||||
as: 'learningCharacter'
|
||||
});
|
||||
|
||||
FalukantCharacter.hasMany(Learning, {
|
||||
foreignKey: 'associatedLearningCharacterId',
|
||||
as: 'learningsCharacter'
|
||||
});
|
||||
|
||||
FalukantUser.hasMany(Credit, {
|
||||
foreignKey: 'falukantUserId',
|
||||
as: 'credits'
|
||||
});
|
||||
Credit.belongsTo(FalukantUser, {
|
||||
foreignKey: 'falukantUserId',
|
||||
as: 'user'
|
||||
});
|
||||
|
||||
FalukantCharacter.hasMany(DebtorsPrism, {
|
||||
foreignKey: 'character_id',
|
||||
as: 'debtorsPrisms'
|
||||
});
|
||||
DebtorsPrism.belongsTo(FalukantCharacter, {
|
||||
foreignKey: 'character_id',
|
||||
as: 'character'
|
||||
});
|
||||
|
||||
HealthActivity.belongsTo(FalukantCharacter, {
|
||||
foreignKey: 'character_id',
|
||||
as: 'character'
|
||||
});
|
||||
FalukantCharacter.hasMany(HealthActivity, {
|
||||
foreignKey: 'character_id',
|
||||
as: 'healthActivities'
|
||||
});
|
||||
|
||||
// — Political Offices —
|
||||
|
||||
// predefine requirements for office
|
||||
PoliticalOfficeRequirement.belongsTo(PoliticalOfficeType, {
|
||||
TitleOfNobility.hasMany(HouseType, { foreignKey: 'minimumNobleTitle', as: 'houseTypes' });
|
||||
HouseType.belongsTo(TitleOfNobility, { foreignKey: 'minimumNobleTitle', as: 'titleOfNobility' });
|
||||
|
||||
PartyType.hasMany(Party, { foreignKey: 'partyTypeId', as: 'parties' });
|
||||
Party.belongsTo(PartyType, { foreignKey: 'partyTypeId', as: 'partyType' });
|
||||
|
||||
MusicType.hasMany(Party, { foreignKey: 'musicTypeId', as: 'parties' });
|
||||
Party.belongsTo(MusicType, { foreignKey: 'musicTypeId', as: 'musicType' });
|
||||
|
||||
BanquetteType.hasMany(Party, { foreignKey: 'banquetteTypeId', as: 'parties' });
|
||||
Party.belongsTo(BanquetteType, { foreignKey: 'banquetteTypeId', as: 'banquetteType' });
|
||||
|
||||
FalukantUser.hasMany(Party, { foreignKey: 'falukantUserId', as: 'parties' });
|
||||
Party.belongsTo(FalukantUser, { foreignKey: 'falukantUserId', as: 'partyUser' });
|
||||
|
||||
Party.belongsToMany(TitleOfNobility, {
|
||||
through: PartyInvitedNobility,
|
||||
foreignKey: 'party_id',
|
||||
otherKey: 'title_of_nobility_id',
|
||||
as: 'invitedNobilities',
|
||||
});
|
||||
TitleOfNobility.belongsToMany(Party, {
|
||||
through: PartyInvitedNobility,
|
||||
foreignKey: 'title_of_nobility_id',
|
||||
otherKey: 'party_id',
|
||||
as: 'partiesInvitedTo',
|
||||
});
|
||||
|
||||
ChildRelation.belongsTo(FalukantCharacter, {
|
||||
foreignKey: 'fatherCharacterId',
|
||||
as: 'father'
|
||||
});
|
||||
FalukantCharacter.hasMany(ChildRelation, {
|
||||
foreignKey: 'fatherCharacterId',
|
||||
as: 'childrenFather'
|
||||
});
|
||||
|
||||
ChildRelation.belongsTo(FalukantCharacter, {
|
||||
foreignKey: 'motherCharacterId',
|
||||
as: 'mother'
|
||||
});
|
||||
FalukantCharacter.hasMany(ChildRelation, {
|
||||
foreignKey: 'motherCharacterId',
|
||||
as: 'childrenMother'
|
||||
});
|
||||
|
||||
ChildRelation.belongsTo(FalukantCharacter, {
|
||||
foreignKey: 'childCharacterId',
|
||||
as: 'child'
|
||||
});
|
||||
FalukantCharacter.hasMany(ChildRelation, {
|
||||
foreignKey: 'childCharacterId',
|
||||
as: 'parentRelations'
|
||||
});
|
||||
|
||||
Learning.belongsTo(LearnRecipient, {
|
||||
foreignKey: 'learningRecipientId',
|
||||
as: 'recipient'
|
||||
}
|
||||
);
|
||||
|
||||
LearnRecipient.hasMany(Learning, {
|
||||
foreignKey: 'learningRecipientId',
|
||||
as: 'learnings'
|
||||
});
|
||||
|
||||
Learning.belongsTo(FalukantUser, {
|
||||
foreignKey: 'associatedFalukantUserId',
|
||||
as: 'learner'
|
||||
}
|
||||
);
|
||||
|
||||
FalukantUser.hasMany(Learning, {
|
||||
foreignKey: 'associatedFalukantUserId',
|
||||
as: 'learnings'
|
||||
});
|
||||
|
||||
Learning.belongsTo(ProductType, {
|
||||
foreignKey: 'productId',
|
||||
as: 'productType'
|
||||
});
|
||||
|
||||
ProductType.hasMany(Learning, {
|
||||
foreignKey: 'productId',
|
||||
as: 'learnings'
|
||||
});
|
||||
|
||||
Learning.belongsTo(FalukantCharacter, {
|
||||
foreignKey: 'associatedLearningCharacterId',
|
||||
as: 'learningCharacter'
|
||||
});
|
||||
|
||||
FalukantCharacter.hasMany(Learning, {
|
||||
foreignKey: 'associatedLearningCharacterId',
|
||||
as: 'learningsCharacter'
|
||||
});
|
||||
|
||||
FalukantUser.hasMany(Credit, {
|
||||
foreignKey: 'falukantUserId',
|
||||
as: 'credits'
|
||||
});
|
||||
Credit.belongsTo(FalukantUser, {
|
||||
foreignKey: 'falukantUserId',
|
||||
as: 'user'
|
||||
});
|
||||
|
||||
FalukantCharacter.hasMany(DebtorsPrism, {
|
||||
foreignKey: 'character_id',
|
||||
as: 'debtorsPrisms'
|
||||
});
|
||||
DebtorsPrism.belongsTo(FalukantCharacter, {
|
||||
foreignKey: 'character_id',
|
||||
as: 'character'
|
||||
});
|
||||
|
||||
HealthActivity.belongsTo(FalukantCharacter, {
|
||||
foreignKey: 'character_id',
|
||||
as: 'character'
|
||||
});
|
||||
FalukantCharacter.hasMany(HealthActivity, {
|
||||
foreignKey: 'character_id',
|
||||
as: 'healthActivities'
|
||||
});
|
||||
|
||||
// — Political Offices —
|
||||
|
||||
// predefine requirements for office
|
||||
PoliticalOfficeRequirement.belongsTo(PoliticalOfficeType, {
|
||||
foreignKey: 'officeTypeId',
|
||||
as: 'officeType'
|
||||
});
|
||||
@@ -520,9 +523,9 @@ PoliticalOfficeRequirement.belongsTo(PoliticalOfficeType, {
|
||||
foreignKey: 'officeTypeId',
|
||||
as: 'requirements'
|
||||
});
|
||||
|
||||
|
||||
// predefine benefits for office
|
||||
PoliticalOfficeBenefit.belongsTo(
|
||||
PoliticalOfficeBenefit.belongsTo(
|
||||
PoliticalOfficeBenefitType,
|
||||
{ foreignKey: 'benefitTypeId', as: 'benefitDefinition' }
|
||||
);
|
||||
@@ -530,7 +533,7 @@ PoliticalOfficeRequirement.belongsTo(PoliticalOfficeType, {
|
||||
PoliticalOfficeBenefit,
|
||||
{ foreignKey: 'benefitTypeId', as: 'benefitDefinitions' }
|
||||
);
|
||||
|
||||
|
||||
// tie benefits back to office type
|
||||
PoliticalOfficeBenefit.belongsTo(PoliticalOfficeType, {
|
||||
foreignKey: 'officeTypeId',
|
||||
@@ -540,7 +543,7 @@ PoliticalOfficeRequirement.belongsTo(PoliticalOfficeType, {
|
||||
foreignKey: 'officeTypeId',
|
||||
as: 'benefits'
|
||||
});
|
||||
|
||||
|
||||
// actual office holdings
|
||||
PoliticalOffice.belongsTo(PoliticalOfficeType, {
|
||||
foreignKey: 'officeTypeId',
|
||||
@@ -550,16 +553,16 @@ PoliticalOfficeRequirement.belongsTo(PoliticalOfficeType, {
|
||||
foreignKey: 'officeTypeId',
|
||||
as: 'offices'
|
||||
});
|
||||
|
||||
|
||||
PoliticalOffice.belongsTo(FalukantCharacter, {
|
||||
foreignKey: 'characterId',
|
||||
as: 'holder'
|
||||
});
|
||||
FalukantCharacter.hasMany(PoliticalOffice, {
|
||||
FalukantCharacter.hasOne(PoliticalOffice, {
|
||||
foreignKey: 'characterId',
|
||||
as: 'heldOffices'
|
||||
as: 'heldOffice'
|
||||
});
|
||||
|
||||
|
||||
// elections
|
||||
Election.belongsTo(PoliticalOfficeType, {
|
||||
foreignKey: 'officeTypeId',
|
||||
@@ -569,7 +572,17 @@ PoliticalOfficeRequirement.belongsTo(PoliticalOfficeType, {
|
||||
foreignKey: 'officeTypeId',
|
||||
as: 'elections'
|
||||
});
|
||||
|
||||
|
||||
Election.belongsTo(RegionData, {
|
||||
foreignKey: 'regionId',
|
||||
as: 'region'
|
||||
});
|
||||
|
||||
RegionData.hasMany(Election, {
|
||||
foreignKey: 'regionId',
|
||||
as: 'elections'
|
||||
});
|
||||
|
||||
// candidates in an election
|
||||
Candidate.belongsTo(Election, {
|
||||
foreignKey: 'electionId',
|
||||
@@ -579,7 +592,7 @@ PoliticalOfficeRequirement.belongsTo(PoliticalOfficeType, {
|
||||
foreignKey: 'electionId',
|
||||
as: 'candidates'
|
||||
});
|
||||
|
||||
|
||||
Candidate.belongsTo(FalukantCharacter, {
|
||||
foreignKey: 'characterId',
|
||||
as: 'character'
|
||||
@@ -588,7 +601,7 @@ PoliticalOfficeRequirement.belongsTo(PoliticalOfficeType, {
|
||||
foreignKey: 'characterId',
|
||||
as: 'candidacies'
|
||||
});
|
||||
|
||||
|
||||
// votes cast
|
||||
Vote.belongsTo(Election, {
|
||||
foreignKey: 'electionId',
|
||||
@@ -598,7 +611,7 @@ PoliticalOfficeRequirement.belongsTo(PoliticalOfficeType, {
|
||||
foreignKey: 'electionId',
|
||||
as: 'votes'
|
||||
});
|
||||
|
||||
|
||||
Vote.belongsTo(Candidate, {
|
||||
foreignKey: 'candidateId',
|
||||
as: 'candidate'
|
||||
@@ -607,7 +620,7 @@ PoliticalOfficeRequirement.belongsTo(PoliticalOfficeType, {
|
||||
foreignKey: 'candidateId',
|
||||
as: 'votes'
|
||||
});
|
||||
|
||||
|
||||
Vote.belongsTo(FalukantCharacter, {
|
||||
foreignKey: 'voterCharacterId',
|
||||
as: 'voter'
|
||||
@@ -616,7 +629,7 @@ PoliticalOfficeRequirement.belongsTo(PoliticalOfficeType, {
|
||||
foreignKey: 'voterCharacterId',
|
||||
as: 'votesCast'
|
||||
});
|
||||
|
||||
|
||||
// election results
|
||||
ElectionResult.belongsTo(Election, {
|
||||
foreignKey: 'electionId',
|
||||
@@ -626,7 +639,7 @@ PoliticalOfficeRequirement.belongsTo(PoliticalOfficeType, {
|
||||
foreignKey: 'electionId',
|
||||
as: 'results'
|
||||
});
|
||||
|
||||
|
||||
ElectionResult.belongsTo(Candidate, {
|
||||
foreignKey: 'candidateId',
|
||||
as: 'candidate'
|
||||
@@ -645,4 +658,43 @@ PoliticalOfficeRequirement.belongsTo(PoliticalOfficeType, {
|
||||
as: 'offices'
|
||||
});
|
||||
|
||||
PoliticalOfficePrerequisite.belongsTo(PoliticalOfficeType, {
|
||||
foreignKey: 'office_type_id',
|
||||
as: 'officeTypePrerequisite',
|
||||
});
|
||||
|
||||
PoliticalOfficeType.hasMany(PoliticalOfficePrerequisite, {
|
||||
foreignKey: 'office_type_id',
|
||||
as: 'prerequisites',
|
||||
});
|
||||
|
||||
PoliticalOfficeHistory.belongsTo(PoliticalOfficeType, {
|
||||
foreignKey: 'officeTypeId',
|
||||
as: 'officeTypeHistory',
|
||||
});
|
||||
|
||||
PoliticalOfficeType.hasMany(PoliticalOfficeHistory, {
|
||||
foreignKey: 'officeTypeId',
|
||||
as: 'history',
|
||||
});
|
||||
|
||||
FalukantCharacter.hasMany(PoliticalOfficeHistory, {
|
||||
foreignKey: 'characterId',
|
||||
as: 'officeHistories',
|
||||
});
|
||||
PoliticalOfficeHistory.belongsTo(FalukantCharacter, {
|
||||
foreignKey: 'characterId',
|
||||
as: 'character',
|
||||
});
|
||||
|
||||
ElectionHistory.belongsTo(PoliticalOfficeType, {
|
||||
foreignKey: 'officeTypeId',
|
||||
as: 'officeTypeHistory',
|
||||
});
|
||||
|
||||
PoliticalOfficeType.hasMany(ElectionHistory, {
|
||||
foreignKey: 'officeTypeId',
|
||||
as: 'electionHistory',
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user