Note 01 — MongoDB connection commands for the Backend .

Nadunatugoda
May 1, 2024

--

why this is for?

This Draft is for fellows to gain direct knowledge about the connection of the database in Mongodb shell with the backend.

Go with the following commands and the ScreenShots for the easierness.

Figure 01 — Create a separate folder called the mongo-db-data.

Step 01 — You need go configure and set upthe environmental variables for the mongodb-shell and then work with the mongodb-shell to achieve the witness.

Step 02 — Go inside the project backend

Step 03 — Try out the following commands and the outputs with the example code base.

01. The example code snippets for the testing.

Figure 02 — The backend code part with inclusive data for the subsequent testing.

02. Following will be the connection and the mongodb-shell execution.

Figure 03 — Command will be mongodb or mongosh (obvious it’s mongosh to get the shell execution.)

03. Created a new database and switched to it from the main.

Figure 04— Creation of new database.

04. Command to insert the data in thebackend to it.

Figure 05 — Data insertion.

05. Displaying data in a coherent mode.

Figure 06 — Displaying data in a prettier mode.

--

--

Nadunatugoda

University of Moratuwa (undergraduate Faculty of IT )