summaryrefslogtreecommitdiff
path: root/model.js
blob: cb78ff7a49e07e6bbc7ce44a3cefb3b3a77801ee (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
/* jshint esnext:true */
"use strict";

module.exports = (seq, Seq) => {
    let // core data
        Match = seq.import("./models/match.js"),
        Asset = seq.import("./models/asset.js"),
        Roster = seq.import("./models/roster.js"),
        Participant = seq.import("./models/participant.js"),
        Player = seq.import("./models/player.js"),

        // mappings
        Item = seq.import("./models/item.js"),
        Hero = seq.import("./models/hero.js"),
        Series = seq.import("./models/series.js"),
        GameMode = seq.import("./models/game_mode.js"),
        Role = seq.import("./models/role.js"),
        Filter = seq.import("./models/filter.js"),

        // Telemetry
        ItemParticipant = seq.import("./models/item_participant.js"),

        // data stats
        ParticipantStats = seq.import("./models/participant_stats.js"),

        // stats aggregations
        PlayerPoint = seq.import("./models/player_point.js"),
        GlobalPoint = seq.import("./models/global_point.js"),

        // registered special users
        Gamer = seq.import("./models/gamer.js");


    Roster.belongsTo(Match, { foreignKey: "match_api_id", targetKey: "api_id" });
    Participant.belongsTo(Roster, { foreignKey: "roster_api_id", targetKey: "api_id" });
    Participant.hasMany(ItemParticipant, { as: "items", foreignKey: "participant_api_id", sourceKey: "api_id" });
    Participant.hasMany(ParticipantStats, { as: "participant_stats", foreignKey: "participant_api_id", sourceKey: "api_id" });
    Participant.belongsTo(GameMode, { foreignKey: "game_mode_id" });
    Participant.belongsTo(Hero, { foreignKey: "hero_id" });
    Participant.belongsTo(Series, { foreignKey: "series_id" });
    Participant.belongsTo(Role, { foreignKey: "role_id" });
    ParticipantStats.belongsTo(Participant, { foreignKey: "participant_api_id", "targetKey": "api_id" });
    ItemParticipant.belongsTo(Item, { foreignKey: "item_id", targetKey: "id" });

    return {
        Match, Roster, Participant, Player, Asset,
        Item, Hero, Series, GameMode, Role, Filter,
        ItemParticipant,
        ParticipantStats,
        PlayerPoint, GlobalPoint,
        Gamer
    };
};