This repo outlines best practices when developing in NodeJS.
I have provided the callConnectDB.js file that demonstrates how to use the connectDB.js file as promised!
How to centralize your database access to your NodeJs Application
How to create a wrapper function to fetch and persist data to your database
How to wrap your queries in rollback transactions without obscuring your code
How to commit your insert and update statements without obsuring your code
How to easily return the data retrieved from the database to your calling function