Began integrating dashboard.

Also fixed match controller populate calls.
This commit is contained in:
2022-04-05 14:52:19 -05:00
parent e4db4ab403
commit 8a7fbd074b
5 changed files with 40 additions and 33 deletions

View File

@@ -48,12 +48,12 @@ MatchController.get("/recent/:limit?", needDatabase, async (req, res) => {
}
let recent = null;
if (user) {
await user.populate("participatingMatches");
await user.populate("participatingMatches").populate("participatingMatches.members.$");
recent = user.participatingMatches.slice(-limit);
} else {
recent = await matchModel.find().where("publicity").gte(2).limit(limit).sort({ createDate: -1 });
recent = await matchModel.find().where("publicity").gte(2).limit(limit).sort({ createDate: -1 }).populate("members.$");
}
await recent.populate("members.$"); // Populates all references.
await recent; // Populates all references.
res.status(200).send({ recent: recent });
} catch (error) {
console.error(error);