Pregunta de entrevista de Infosys

Write the code to connect to any database using nodejs

Respuesta de la entrevista

Anónimo

12 de nov de 2024

I chose to use mysql. My response was to import the MySQL package and use the createConnection method to establish a connection by passing in database credentials like the host URL, username, and password as arguments. While I didn’t recall the exact function name at that moment, I explained that it was either mysql.createConnection(params) or mysql.connect(params), and I also wrote a prototype of this method to demonstrate my understanding.