I am getting the error "MongoError: Cannot use a session that has ended" and after looking through a few other stackoverflow similar questions, majority of have been solved by using async/await due to the doing multiple things at once. I tried this my self but with no luck, In may case I am doing a single action and still getting this error.
Any suggestions or tips?
const mongodb = require('mongodb');
const mongoclient = mongodb.MongoClient;
const client = new mongoclient(uri, { useNewUrlParser: true, useUnifiedTopology: true });
client.connect(err => {
if(err) return console.log(err);
const collection = client.db(databasename).collection(nameofcollection);
collection.insertMany(details);
client.close();
});