-
Notifications
You must be signed in to change notification settings - Fork 1
/
db.ts
68 lines (63 loc) · 1.47 KB
/
db.ts
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
import mongoose, { Schema } from 'mongoose';
const matchSchema = new Schema(
{
metadata: {
dataVersion: String,
matchId: { type: String, index: { unique: true } },
participants: { type: [String], index: true },
},
info: {
participants: [
{
puuid: { type: String, index: true },
win: Boolean,
pentaKills: Number,
championName: String,
summonerName: String,
},
],
},
},
{ strict: false }
);
const champSchema = new Schema({
champion: String,
games: Number,
wins: Number,
losses: Number,
winrate: Number,
pentaKills: Number,
});
const statsSchema = new Schema({
puuid: {type: String, index: true},
summonerName: {type: String, index: true},
lowerCaseName: {type: String, index: true},
champStats: [champSchema],
matchStats: {
summonerName: String,
puuid: String,
games: Number,
wins: Number,
losses: Number,
winrate: Number,
pentaKills: Number,
},
allyStats: [
{
summonerName: String,
games: Number,
wins: Number,
losses: Number,
winrate: Number,
}
]
});
const matchConnection = mongoose.createConnection(
'mongodb://localhost:27017/aram-matches'
);
const Match = matchConnection.model('Match', matchSchema);
const statsConnection = mongoose.createConnection(
'mongodb://localhost:27017/aram-stats'
);
const Stats = statsConnection.model('Stats', statsSchema);
export { Match, Stats};