Learn NodeJS in 1 Day: Complete Node JS Guide with Examples by Krishna Rungta

Learn NodeJS in 1 Day: Complete Node JS Guide with Examples by Krishna Rungta

Author:Krishna Rungta
Language: eng
Format: azw3, epub, pdf
Published: 2016-11-24T08:00:00+00:00


The first is 'mongodb' which specifies that we are connecting to a mongoDB database.

The next is 'localhost' which means we are connecting to a database on the local machine.

The next is 'EmployeeDB' which is the name of the database defined in our MongoDB database.

The next step is to actually connect to our database. The connect function takes in our URL and has the facility to specify a callback function. It will be called when the connection is opened to the database. This gives us the opportunity to know if the database connection was successful or not.

In the function, we are writing the string "Connection established" to the console to indicate that a successful connection was created.

Finally, we are closing the connection using the db.close statement.



Download



Copyright Disclaimer:
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.