MongoDB - open and close connection - advise for good practice
<p>I am using MongoDB via its driver for node.js</p>

<p>I typically open a connection (via the <code>connect()</code> method) any time I need to perform an operation and close it (via the <code>close()</code> method) as soon as I am finished. In my programs, as natural, I need to perform many operations against the MongoDB and therefore it happens that I open and close many times the connection.</p>

<p>I am wondering whether this is a good practice or whether it would be better to open the connection as the first operation is executed, store it in a variable and use the already opened connections for the following operations closing it when the program ends.</p>

<p>Any advice is very much appreciated.</p>