1//we are in ./utils/dbHelper.js, here we have some helper functions
2function connect() {
3 // connect do db...
4}
5
6function closeConnection() {
7 // close connection to DB...
8}
9
10//let's export this function to show them to the world outside
11module.exports = {
12 connect(),
13 closeConnection()
14};
15
16// now we are in ./main.js and we want use helper functions from dbHelper.js
17const DbHelper = require ('./utils/dbHelper'); // import all file and name it DbHelper
18DbHelper.connect(); // use function from './utils/dbHelper' using dot(.)
19
20// or we can import only chosen function(s)
21const { connect, closeConnection } = require ('./utils/dbHelper');
22connect(); // use function from class without dot