summaryrefslogtreecommitdiff
path: root/model.js
blob: fa7c51705cc6bd97438b58fd1f4afec17782313f (plain)
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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
/* jshint esnext:true */
'use strict';

var JsonField = require("sequelize-json");

module.exports = (seq, Seq) => {
    let Player = seq.define("player", {
        id: { type: Seq.STRING, unique: true, primaryKey: true },
        /* attributes */
        name: Seq.STRING,
        shardId: Seq.STRING,
        /* stats */
        level: Seq.INTEGER,
        lifetimeGold: Seq.DECIMAL,
        lossStreak: Seq.INTEGER,
        played: Seq.INTEGER,
        played_ranked: Seq.INTEGER,
        winStreak: Seq.INTEGER,
        wins: Seq.INTEGER,
        xp: Seq.INTEGER
    }, {
        freezeTableName: true,
        underscored: true
    });
    let Team = seq.define("team", {
        id: { type: Seq.STRING, unique: true, primaryKey: true },
        /* attributes */
        name: Seq.STRING,
        shardId: Seq.STRING
        /* stats */
    }, {
        freezeTableName: true,
        underscored: true
    });
    let Asset = seq.define("asset", {
        id: { type: Seq.STRING, unique: true, primaryKey: true },
        /* attributes */
        URL: Seq.STRING,
        contentType: Seq.STRING,
        createdAt: Seq.DATE,
        description: Seq.TEXT,
        filename: Seq.STRING,
        name: Seq.STRING
    }, {
        freezeTableName: true,
        underscored: true,
        createdAt: false
    });
    let Match = seq.define("match", {
        id: { type: Seq.STRING, unique: true, primaryKey: true },
        /* attributes */
        createdAt: Seq.DATE,
        duration: Seq.INTEGER,
        gameMode: Seq.STRING,
        patchVersion: Seq.STRING,
        shardId: Seq.STRING,
        /* stats */
        endGameReason: Seq.STRING,
        queue: Seq.STRING
    }, {
        freezeTableName: true,
        underscored: true,
        createdAt: false
    });
    let Roster = seq.define("roster", {
        id: { type: Seq.STRING, unique: true, primaryKey: true },
        /* attributes */
        /* stats */
        acesEarned: Seq.INTEGER,
        gold: Seq.INTEGER,
        heroKills: Seq.INTEGER,
        krakenCaptures: Seq.INTEGER,
        side: Seq.STRING,
        turretKills: Seq.INTEGER,
        turretsRemaining: Seq.INTEGER,
    }, {
        freezeTableName: true,
        underscored: true
    });
    let Participant = seq.define("participant", {
        id: { type: Seq.STRING, unique: true, primaryKey: true },
        /* attributes */
        actor: Seq.STRING,
        /* stats */
        assists: Seq.INTEGER,
        crystalMineCaptures: Seq.INTEGER,
        deaths: Seq.INTEGER,
        farm: Seq.DECIMAL,
        firstAfkTime: Seq.INTEGER,
        goldMineCaptures: Seq.INTEGER,
        itemGrants: JsonField(seq, "Participant", "itemGrants"),
        itemSells: JsonField(seq, "Participant", "itemSells"),
        itemUses: JsonField(seq, "Participant", "itemUses"),
        items: JsonField(seq, "Participant", "items"),
        jungleKills: Seq.INTEGER,
        karmaLevel: Seq.INTEGER,
        kills: Seq.INTEGER,
        krakenCaptures: Seq.INTEGER,
        level: Seq.INTEGER,
        minionKills: Seq.INTEGER,
        nonJungleMinionKills: Seq.INTEGER,
        skillTier: Seq.INTEGER,
        skinKey: Seq.STRING,
        turretCaptures: Seq.INTEGER,
        wentAfk: Seq.BOOLEAN,
        winner: Seq.BOOLEAN,
    }, {
        freezeTableName: true,
        underscored: true
    });

    Match.hasMany(Roster, {as: "Rosters"});
    Match.hasMany(Asset, {as: "Assets"});
    Asset.belongsTo(Match);
    Roster.belongsTo(Match);
    Roster.hasMany(Participant, {as: "Participants"});
    Roster.hasOne(Team, {as: "Team"});
    Team.belongsTo(Roster);
    Participant.belongsTo(Roster);
    Participant.belongsTo(Player);

    return {Match, Roster, Team, Participant, Player, Asset};
};