Is it possible to update the following code snippet to end gracefully after inserting a new document, {name:'r2'}
?
var MongoClient = require ('mongodb').MongoClient;
MongoClient.connect ('mongodb://localhost:27017/dbA', function (err, db) {
if (err) {
console.log (err);
} else {
var collection = db.collection ('colA');
collection.insert ({name: 'r2'});
} // <-- Is there another way this can be written to ensure successful termination?
});