Question d’entretien chez Infosys

Write the code to connect to any database using nodejs

Réponse à la question d'entretien

Utilisateur anonyme

12 nov. 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.