Correct the insert function in base repository.

This commit is contained in:
Pierre THIERRY
2020-09-06 11:54:57 +02:00
parent c618675a9a
commit 14da8bf0f1

View File

@@ -14,12 +14,6 @@ class MongoClient {
assert.equal(null, err); assert.equal(null, err);
console.log('Connected successfuly to mongodb'); console.log('Connected successfuly to mongodb');
this.db = client.db(mongoConfig.database); 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) => { this.db.collection(collectionName).insert(entity, (error, result) => {
assert.equal(null, error, `Unable to insert ${collectionName} entity: ${error}.`); assert.equal(null, error, `Unable to insert ${collectionName} entity: ${error}.`);
console.log(`Entity ${collectionName} inserted.`); console.log(`Entity ${collectionName} inserted.`);
callback(result); // Return only the inserted document.
callback(result.ops[0]);
}); });
} }