'how do i make nodejs mongodb handler

I'm going to create separate files and I don't want to type a connect command for each one again and again how can I convert the connect command to the handler

const MongoClient = require('mongodb').MongoClient;
const uri = "URL";
MongoClient.connect(uri, (err, clientdata) => {

})


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source