From 14da8bf0f15d40da9a11215889b59bb91bdea493 Mon Sep 17 00:00:00 2001 From: Pierre THIERRY Date: Sun, 6 Sep 2020 11:54:57 +0200 Subject: [PATCH] Correct the insert function in base repository. --- src/js/mongoClient.js | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/src/js/mongoClient.js b/src/js/mongoClient.js index 084e29f..df3ec58 100644 --- a/src/js/mongoClient.js +++ b/src/js/mongoClient.js @@ -14,12 +14,6 @@ class MongoClient { assert.equal(null, err); console.log('Connected successfuly to mongodb'); this.db = client.db(mongoConfig.database); - - this.db.collection('test').find({}, (err, results) => { - results.forEach(console.log); - }); - - // client.close(); }); } @@ -37,7 +31,8 @@ class MongoClient { this.db.collection(collectionName).insert(entity, (error, result) => { assert.equal(null, error, `Unable to insert ${collectionName} entity: ${error}.`); console.log(`Entity ${collectionName} inserted.`); - callback(result); + // Return only the inserted document. + callback(result.ops[0]); }); }