diff options
| author | schneefux <schneefux+commit@schneefux.xyz> | 2017-03-29 20:31:05 +0200 |
|---|---|---|
| committer | schneefux <schneefux+commit@schneefux.xyz> | 2017-03-29 20:31:05 +0200 |
| commit | 5c869aa26666215ec4ea5315b40fea3025a1ae83 (patch) | |
| tree | 7d1468587aa899fd364a5e96d193665e0bba61bb /model.js | |
| parent | 202d7641749b817c8893cc07918e23b211c92ba7 (diff) | |
| download | processor-5c869aa26666215ec4ea5315b40fea3025a1ae83.tar.gz processor-5c869aa26666215ec4ea5315b40fea3025a1ae83.zip | |
import db schema from vainsocial
Diffstat (limited to 'model.js')
| -rw-r--r-- | model.js | 127 |
1 files changed, 13 insertions, 114 deletions
@@ -4,120 +4,19 @@ 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 - }); + let Match = seq.import("./models/match.js"), + Roster = seq.import("./models/roster.js"), + Participant = seq.import("./models/participant.js"), + Player = seq.import("./models/player.js"); - 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); + //Match.hasMany(Asset, {as: "Assets"}); + //Asset.belongsTo(Match); + Roster.belongsTo(Match, { foreignKey: "match_api_id", targetKey: "api_id" }); + //Roster.hasOne(Team, {as: "Team"}); + //Team.belongsTo(Roster); + Participant.belongsTo(Roster, { foreignKey: "roster_api_id", targetKey: "api_id" }); + Participant.hasOne(Player, { foreignKey: "player_api_id", targetKey: "api_id" }); - return {Match, Roster, Team, Participant, Player, Asset}; + //return {Match, Roster, Team, Participant, Player, Asset}; + return {Match, Roster, Participant, Player}; }; |
