Correct the insert function in base repository.
This commit is contained in:
@@ -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]);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user