From e333ecc6db4759f3f11d8343ce4f980044682c12 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?In=C3=A8s=20Yeterian?= <ines.yeterian@student-cs.fr>
Date: Sun, 16 Jan 2022 20:07:17 +0100
Subject: [PATCH] try to speak mangoose

---
 backend/routes/routesToucan.js | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/backend/routes/routesToucan.js b/backend/routes/routesToucan.js
index 818b89a..5e2f27f 100644
--- a/backend/routes/routesToucan.js
+++ b/backend/routes/routesToucan.js
@@ -19,8 +19,12 @@ const urltoucans = Toucan.aggregate([
                 {input: "$titlelc",initialValue: "",
                 in: { $concat : ["$$value", "$$this"]}}} }}, 
     {$addFields:
-        {urlId:
+        {urlIdstring:
             {$concat:["$titlelcnospace","-","$year"]}}}, 
+    {$addFields:
+        {urlId:
+            {$toObjectId :"$urlIdstring"}
+        }},
     {$unset:["titlelc","year","titlelcnospace","title","date"]}, 
 ]);
 
@@ -158,7 +162,7 @@ router.route("/img/:id")
         try {  
               console.log(req.params.url);
               urltoucans.
-              match({urlID: mongoose.Types.String('boule-2022')}).
+              match({urlID: mongoose.Types.ObjectId('boule-2022')}).
               exec((err,data) => {
                 if (err) {
                   console.log(err);
-- 
GitLab