From 8797e5e984f8c3571f7b1161740b3912e7e8692a Mon Sep 17 00:00:00 2001 From: Adolfo Reyna Date: Wed, 8 Sep 2021 13:58:03 -0700 Subject: [PATCH] courses are requested separately --- dbTools/profile.js | 13 ++++++++++++- routes/profile.js | 8 ++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/dbTools/profile.js b/dbTools/profile.js index 6d188a5..90469da 100644 --- a/dbTools/profile.js +++ b/dbTools/profile.js @@ -99,7 +99,7 @@ userDB = (DB) => { //Groups DB.getGroups = async () => { - let r = await DB.profileCols.find({isGroup: true}) + let r = await DB.profileCols.find({isGroup: true, isCourse: {$ne: true}}) .sort({ lastUpdate: -1 }).limit(10) .toArray().catch((err) => { console.log(err); @@ -148,6 +148,17 @@ userDB = (DB) => { }); } + //Courses + DB.getCourses = async () => { + let r = await DB.profileCols.find({isGroup: true, isCourse: true}) + .sort({ lastUpdate: -1 }).limit(10) + .toArray().catch((err) => { + console.log(err); + return false; + }); + return r; + } + } module.exports = userDB; \ No newline at end of file diff --git a/routes/profile.js b/routes/profile.js index ece3d7d..e08fde2 100644 --- a/routes/profile.js +++ b/routes/profile.js @@ -60,6 +60,14 @@ DB.getDB.then((DB)=>{ }); }); + router.get("/courses", async (req, res) => { + let groups = await DB.getCourses(); + return res.json({ + status: "ok", + groups + }); + }); + router.get("/groups/:id", async (req, res) => { const groupid = req.params.id; let groups = await DB.getGroup(groupid);