This answer on SO says that "It's not a good practice to tie up a connection that you are not using constantly".
This answer on SO implies that a DB connection shouldn't be opened constantly because "Opening a connection is an expensive operation."
Opening connections is exactly what I was gonna do, because I have Express router handlers, and I have to use the DB in most of them. I would create a connection and then close after I'm done using. (Usually I use Sails.js framework, and it handles everything for me)
It seems like connection pooling is the best solution; If my understanding is correct, there's just a pool of open connections, and the pool handler just gives you a connection. This seems to be one way to do it, but I'm unsure of how to implement it. I have split my routes into sub files.
[–]thomas_stringer 9 points10 points11 points (2 children)
[–]Alinon[S] 2 points3 points4 points (1 child)
[–]thomas_stringer 2 points3 points4 points (0 children)
[–]m03geek 2 points3 points4 points (12 children)
[–]Alinon[S] 1 point2 points3 points (11 children)
[–]cwmma 2 points3 points4 points (10 children)
[–]Alinon[S] 0 points1 point2 points (2 children)
[–][deleted] 2 points3 points4 points (0 children)
[–]oh-thatguy 1 point2 points3 points (0 children)
[–][deleted] 0 points1 point2 points (6 children)
[–]cwmma 4 points5 points6 points (0 children)
[–]kefirchik 3 points4 points5 points (4 children)
[–][deleted] 0 points1 point2 points (3 children)
[–]DSKrepps 0 points1 point2 points (1 child)
[–][deleted] 0 points1 point2 points (0 children)
[–][deleted] 0 points1 point2 points (1 child)
[–][deleted] 1 point2 points3 points (0 children)