I would like to know if I am to use createConnection instead of using createPool, does it mean that the createConnection pool will be automatically created and closed when done with the query?
Many thanks in advance.
What is the different createConnection vs createPool of MySQL NodeJS and in fact, using createPool the right way to go. Please refer here for the answer.
Connection Pooling (createPool) is a mechanism to maintain a cache of database connection so that the connection can be reused after releasing it. So connections get stored, and do not need to get closed.
While using a connection (createConnection), you only have one connection and it lasts until you close it.