I m using a synchronous call from Express NodeJS to execute my queries in MongoDB using async await. Does this has any adverse performance impacts on the incoming request or any kind of bottleneck that can occur ? So far I have tried multiple request and it works fine. I wanted to know if the incoming number of requests increases significantly, will this result in any adverse of performance issues ?
here is the code how I have setup the MongoDb communication
export const queryToDB = async(queryHandler) => {
let resultSet;
await MongoClient.connect(mongodburl, (err, client) => {
if(err) throw Error("Database connection cannot be established.");
resultSet = queryHandler(client.db("db_name));
});
return resultSet
}
queryHandler example is as follows:
return connection =>
{connection.collection('table_name').insert(value, err => {
if (err) throw new Error(err);
doSomething();
});