From 13a91ad42c6e60bd586fa1638d4635431fcb7bfc Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?In=C3=A8s=20Yeterian?= <ines.yeterian@student-cs.fr>
Date: Tue, 11 Jan 2022 17:47:03 +0100
Subject: [PATCH] added error handling

---
 backend/models/modelToucan.js | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/backend/models/modelToucan.js b/backend/models/modelToucan.js
index ffb5576..6cba87a 100644
--- a/backend/models/modelToucan.js
+++ b/backend/models/modelToucan.js
@@ -15,6 +15,16 @@ var toucanSchema = new Schema ({
 toucanSchema.index({date:-1},{unique: true});
 
 var toucans = mongoose.model("Toucan",toucanSchema);
-await toucans.updateMany( {},{$set: { toucan_id : 'example'} }, { multi: true });
+try{
+await toucans.updateMany( {},{$set: { toucan_id : 'example'} }, { multi: true }, function (err, docs) {
+    if (err){
+        console.log(err)
+    }
+    else{
+        console.log("Updated Docs : ", docs);
+    }
+});
+}
+catch(e) { console.error(e) };
 
 module.exports = toucans;
\ No newline at end of file
-- 
GitLab