Skip to content

Commit

Permalink
Modified players to be 1 to many
Browse files Browse the repository at this point in the history
  • Loading branch information
UO277274 committed Mar 5, 2024
1 parent cbd41d8 commit 83aa05a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 15 deletions.
16 changes: 4 additions & 12 deletions game/gameservice/game-model.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,26 +7,18 @@ const gameSchema = new mongoose.Schema({
type: String,
required: true,
},
player1:{
players:[{
type: mongoose.Schema.Types.ObjectId,ref:'User',
required: true,
},
player1Points:{
type: Number,
required: true,
},
}],
/*
player2:{
type: mongoose.Schema.Types.ObjectId,ref:'User'
},
player2Points:{
type: Number,
},
player3:{
type: mongoose.Schema.Types.ObjectId,ref:'User'
},
player3Points:{
type: Number,
},
*/
questions:[
{
type: mongoose.Schema.Types.ObjectId,ref:'Question4Answers'
Expand Down
5 changes: 2 additions & 3 deletions game/gameservice/game-service.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,11 @@ function validateRequiredFields(req, requiredFields) {
app.post('/creategame', async (req, res) => {
try {
// Check if required fields are present in the request body
validateRequiredFields(req, ['player1', 'player1points']);
validateRequiredFields(req, ['player']);

const newGame = new Game({
//id: TODO: generate unique id
player1: req.body.player1,
player1Points: req.body.player1points,
player1: req.body.player,
questions: req.body.questions,
});

Expand Down

0 comments on commit 83aa05a

Please sign in to comment.