Skip to content

Commit

Permalink
get lastGame by username
Browse files Browse the repository at this point in the history
  • Loading branch information
pelazas committed Mar 7, 2024
1 parent 9c9b11f commit 9887776
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions game/gameservice/GameController.js
Original file line number Diff line number Diff line change
@@ -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;
Expand Down

0 comments on commit 9887776

Please sign in to comment.