diff --git a/README.md b/README.md index 15eae66..7e57dce 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/src/models/events.js b/src/models/events.js new file mode 100644 index 0000000..5db3ccc --- /dev/null +++ b/src/models/events.js @@ -0,0 +1,10 @@ +import { Schema, model } from 'mongoose'; + +const events = new Schema({ + name: { + type: String, + required: true, + }, +}); + +export default model('Events', events); \ No newline at end of file diff --git a/src/models/matches.js b/src/models/matches.js new file mode 100644 index 0000000..c33fa8a --- /dev/null +++ b/src/models/matches.js @@ -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); \ No newline at end of file diff --git a/src/models/rosters.js b/src/models/rosters.js new file mode 100644 index 0000000..55124ee --- /dev/null +++ b/src/models/rosters.js @@ -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); \ No newline at end of file diff --git a/src/models/streams.js b/src/models/streams.js new file mode 100644 index 0000000..fb9ed0f --- /dev/null +++ b/src/models/streams.js @@ -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); \ No newline at end of file