diff --git a/game/gameservice/GameController.js b/game/gameservice/GameController.js index a4fbad9..0b68940 100644 --- a/game/gameservice/GameController.js +++ b/game/gameservice/GameController.js @@ -1,12 +1,17 @@ let Game = require('./game-model'); -let User = require('../../users/userservice/user-model'); +let { userSchema } = require('../../users/userservice/user-model'); +const {question4AnswersSchema} = require("../qgservice/Question4Answers"); const { createGame } = require('./gameLogic'); +const mongoose = require('mongoose'); +const User = mongoose.model('User', userSchema); +const Question4Answers = mongoose.model('Question4Answers', question4AnswersSchema); let GameController = { findByUsername: async (req, res) => { - let game = await User.find({user: req.params.username}).populate("lastgame"); - res.json(game); + let game = await User.find({username: req.params.username}).populate("lastGame") + let response = await Game.findById(game[0].lastGame.id).populate("questions").populate("players") + res.json(response); }, create: async (req, res) => { const { questions, users } = req.body;