how does createConnection work with nodeJS?

101 views
Skip to first unread message

Kiss Koppány

unread,
Oct 19, 2016, 7:27:30 PM10/19/16
to node-mysql

What does createConnection do?

var connection = mysql.createConnection({
  host     : 'example.org',
  user     : 'bob',
  password : 'secret'
});

I'm writing an application in nodeJS using mysql module. I have some own modules, for example authentication, which definetely needs DB connection. Question is: if I have multiple modules where I use this methid to create the connection, will it create a new connection for me everytime or use the first one? If creates, it creates the first time it loads my own module or everytime? Oh, and if it creates when is it going to be destroyed? 

Thanks for the answers.
Reply all
Reply to author
Forward
0 new messages