-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmodels.js
69 lines (66 loc) · 3.38 KB
/
models.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
const Sequelize = require('sequelize');
let e = {};
e.database = new Sequelize(process.env.DB_NAME, process.env.DB_USERNAME, process.env.DB_PASS, {
dialect: 'sqlite',
logging: false,
storage: 'data/database.sqlite',
});
// # Database Models
e.Relic = e.database.import('data/models/relic');
e.World = e.database.import('data/models/world');
e.Status = e.database.import('data/models/status');
e.Skill = e.database.import('data/models/skill');
e.Power = e.database.import('data/models/power');
e.Rebirth = e.database.import('data/models/rebirth');
e.Awakening = e.database.import('data/models/awakening');
e.TortureTool = e.database.import('data/models/torturetool');
e.Keyword = e.database.import('data/models/keyword');
e.Monster = e.database.import('data/models/monster');
e.Hero = e.database.import('data/models/hero');
e.Corrupted = e.database.import('data/models/corrupted');
e.DarkLord = e.database.import('data/models/darklord');
e.Room = e.database.import('data/models/room');
// # Associations
// Monster - Skill
e.Monster.belongsToMany(e.Skill, { through: 'MonsterSkills' });
e.Skill.belongsToMany(e.Monster, { through: 'MonsterSkills' });
// e.Monster - Keyword
e.Monster.belongsToMany(e.Keyword, { through: 'MonsterKeywords' });
e.Keyword.belongsToMany(e.Monster, { through: 'MonsterKeywords' });
// Hero - Skill
e.Hero.belongsToMany(e.Skill, { through: 'HeroSkills' });
e.Skill.belongsToMany(e.Hero, { through: 'HeroSkills' });
// Hero - TortureTool - Best
e.Hero.belongsToMany(e.TortureTool, { as: 'BestTool', through: 'HeroBestTools' });
e.TortureTool.belongsToMany(e.Hero, { as: 'BestHero', through: 'HeroBestTools' });
// Hero - TortureTool - Nice
e.Hero.belongsToMany(e.TortureTool, { as: 'NiceTool', through: 'HeroNiceTools' });
e.TortureTool.belongsToMany(e.Hero, { as: 'NiceHero', through: 'HeroNiceTools' });
// Hero - TortureTool - Normal
e.Hero.belongsToMany(e.TortureTool, { as: 'NormalTool', through: 'HeroNormalTools' });
e.TortureTool.belongsToMany(e.Hero, { as: 'NormalHero', through: 'HeroNormalTools' });
// Hero - TortureTool - Bad
e.Hero.belongsToMany(e.TortureTool, { as: 'BadTool', through: 'HeroBadTools' });
e.TortureTool.belongsToMany(e.Hero, { as: 'BadHero', through: 'HeroBadTools' });
// Hero - TortureTool - Fail
e.Hero.belongsToMany(e.TortureTool, { as: 'FailTool', through: 'HeroFailTools' });
e.TortureTool.belongsToMany(e.Hero, { as: 'FailHero', through: 'HeroFailTools' });
// Hero - TortureTool - Immune
e.Hero.belongsToMany(e.TortureTool, { as: 'ImmuneTool', through: 'HeroImmuneTools' });
e.TortureTool.belongsToMany(e.Hero, { as: 'ImmuneHero', through: 'HeroImmuneTools' });
// Corrupted - Skill
e.Corrupted.belongsToMany(e.Skill, { through: 'CorruptedSkills' });
e.Skill.belongsToMany(e.Corrupted, { through: 'CorruptedSkills' });
// Corrupted - Keyword
e.Corrupted.belongsToMany(e.Keyword, { through: 'CorruptedKeywords' });
e.Keyword.belongsToMany(e.Corrupted, { through: 'CorruptedKeywords' });
// DarkLord - Power
e.DarkLord.belongsToMany(e.Power, { through: 'DarkLordPowers' });
e.Power.belongsToMany(e.DarkLord, { through: 'DarkLordPowers' });
// DarkLord - Rebirth
e.DarkLord.belongsToMany(e.Rebirth, { through: 'DarkLordRebirths' });
e.Rebirth.belongsToMany(e.DarkLord, { through: 'DarkLordRebirths' });
// DarkLord - Awakening
e.DarkLord.belongsToMany(e.Awakening, { through: 'DarkLordAwakenings' });
e.Awakening.belongsToMany(e.DarkLord, { through: 'DarkLordAwakenings' });
module.exports = e;