Home - ManishKakarla/Exercise-N1 GitHub Wiki
Welcome to the Exercise-N1 wiki!
Heroku-Express
Database-Console
1. Heroku-Express
Step 1: Create a project with express and nodejs
Step 2: Install all the required dependencies using npm i express mongodb mongoose ejs
Step 3: Create database for this app using mongodb atlas and also create collection and insert data into the collection and Retrieve data created from the database and it can be verified by using the localhost/db url.
Step 4: Do "npm start". This will run the server locally.
Step 5: Push your code to the github repository and make it public
Step 6: Creating heroku app in the ide terminal with the following commands
a) heroku login
b) heroku create (This will create the heroku app .)
c) git push heroku master (To deploy your app to Heroku, you typically use the git push command to push the code from your local repository’s master or main branch to your heroku remote.)
d) heroku ps:scale web=1
Step 3: Now you can view the "infinite-brook-61397" app running successfully using the URL link
https://infinite-brook-61397.herokuapp.com/db
Step 4: Screenshot of "infinite-brook-61397.herokuapp.com/" running successfully on heroku cloud running on free dynos and web npm start being the main page.
2.Database Console
1. Sign in to your mongoDb Atlas account using the url
https://account.mongodb.com/account/login
2. Click on create a new cluster, then a new cluster would get created for the project
3. Below is the cluster created .Now click on Connect.
4. After clicking on connect, the below window appears. Click on connect your application.
5. Choose a connection method:
Select your driver and version and Add your connection string into your application code
Replace with the password for the Laxmanreddy123 user. Replace myFirstDatabase with the name of the database that connections will use by default. Ensure any option params are URL encoded. Then copy the URL string link and paste it in the MongoDB connection code snippet in the created app
6. I am using Mongo compass here to connect to the cluster and create a database. You can do it in MongoDB Atlas as well.
Click on Create Database and give the Database name and the Collection name.