added models

main
Ayush Mukherjee 4 years ago
parent 20a23b9e1f
commit 5f4b8982a6

@ -6,7 +6,7 @@ through the CMS for creating/updating data.
## Todos
- [ ] data
- [ ] create migrations with stream consideration
- [x] create migrations with stream consideration
- [ ] read from db
- [ ] create data
- [ ] update data

@ -0,0 +1,10 @@
import { Schema, model } from 'mongoose';
const events = new Schema({
name: {
type: String,
required: true,
},
});
export default model('Events', events);

@ -0,0 +1,57 @@
import { Schema, model } from 'mongoose';
const gameScores = new Schema({
orange: {
type: Number,
required: true,
},
blue: {
type: Number,
required: true,
},
});
const matches = new Schema({
orange: {
type: Schema.types.ObjectId,
refs: 'Rosters',
required: true,
},
blue: {
type: Schema.types.ObjectId,
refs: 'Rosters',
required: true,
},
started: {
type: Boolean,
required: true,
},
done: {
type: Boolean,
required: true,
},
type: {
type: String,
required: true,
},
bestOf: {
type: String,
required: true,
},
series: {
orange: {
type: Number,
required: true,
},
blue: {
type: Number,
required: true,
},
},
games: {
type: [gameScores],
required: true,
},
});
export default model('Matches', matches);

@ -0,0 +1,61 @@
import { Schema, model } from 'mongoose';
const stats = new Schema({
goals: {
type: Number,
required: true,
},
assists: {
type: Number,
required: true,
},
saves: {
type: Number,
required: true,
},
shots: {
type: Number,
required: true,
},
demos: {
type: Number,
required: true,
},
});
const players = new Schema({
name: {
type: String,
required: true,
},
account: {
type: String,
required: true,
},
stats: {
type: [stats],
required: true,
},
});
const rosters = new Schema({
event: {
type: Schema.types.ObjectId,
ref: 'Events',
required: true,
},
name: {
type: String,
required: true,
},
logo: {
type: String,
required: true,
},
players: {
type: [players],
required: true,
},
});
export default model('Rosters', rosters);

@ -0,0 +1,20 @@
import { Schema, model } from 'mongoose';
const streams = new Schema({
name: {
type: String,
required: true,
},
event: {
type: Schema.types.ObjectId,
refs: 'Events',
requried: true,
},
matches: {
type: [Schema.types.ObjectId],
refs: 'matches',
requried: true,
},
});
export default model('Streams', streams);
Loading…
Cancel
Save