Does connection with the database via mongoose don't need to be closed?

Hello, while using the mongoose to connect with my Atlas MongoDB I don’t need to close the connection with the database after I do all the stuff that I had to? Also, when I connect to the database in main app file does the modules that are imported to this main file can also use the connection made to the database? Thanks for your help :slight_smile:

You need connection with database as long as your server is running, when you shut the server, mongodb will close connection on connection pool timeout.

After mongoose is connected you don’t use connection, but mongoose itself by importing it to module that needs access to database

1 Like