CRUD with Mongo NoSQL DB
Last Updated: March 24, 2021
In this tutorial, we are getting started with MongoDB compass, that is the official graphical user interface for MongoDB, We will create and drop a database, create collection, add, update and delete data.
Pre-Requisite:
Steps
-
Open MongoDB Compass, and you should see the following screen:
-
Create New Connection, in two ways as follows:
-
Paste your connection String (SRV or Standard), then press Connect
-
-
Fill in Connection fields individually, by filling Hostname, port, selecting the authentication and then press on Connect in following screen:
-
Create Database , by pressing on Create database in the following screen:
-
Fill in Database Name and Collection Name, then press Create Database in the following screen:
-
In the following screen, you should see the database that you have created in the previous step.
-
Click on the database, you should see the following screen with the collection that you named in the previous step:
-
Click on the collection, you should see the following screen:
-
Add data, in the following screen press "Add Data", in two ways Import file or Insert Document
-
Import File, by browsing the file you want to import and selecting Input Type File, then press IMPORT and the data will be imported
-
Insert Document, then fill the data and then press INSERT
-
Edit Document, hover over the document that you want to edit and press Edit Document, apply the changes then press UPDATE, as in the following screens:
-
Delete Document, hover over the document that you want to delete and press Delete Document and then press DELETE
-
Find Data, Fill in the field and the value, then press FIND, then the data will be filter according to the inserted field and value.
| Drop database drops all tables in the database and deletes the database. Be very careful with this statement! |
-
Finally, how to drop a database, in the left side section, hover over the database that you want to drop and press the trash can with tool tip Drop database, as in the following screen: