From 5c869aa26666215ec4ea5315b40fea3025a1ae83 Mon Sep 17 00:00:00 2001 From: schneefux Date: Wed, 29 Mar 2017 20:31:05 +0200 Subject: import db schema from vainsocial --- model.js | 127 +++++++-------------------------------------------------------- 1 file changed, 13 insertions(+), 114 deletions(-) (limited to 'model.js') diff --git a/model.js b/model.js index fa7c517..0ff813e 100644 --- a/model.js +++ b/model.js @@ -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}; }; -- cgit v1.3.1