MongoDB
This section includes tutorials, tips and tricks of using MongoDB
Installation
In this section, we will show you how install MongoDB Community Edition.
-
Scroll to "MongoDB Community Server", in Available Downloads section, Select the Version, Platform and package and press on Download button
![Output](../_images/mongo/mongo-download.png)
-
Open the downloaded file, press Next in the following screen:
![Output](../_images/mongo/mongo-step1.png)
-
Accept the terms in the License Agreement, by clicking on the checkbox next to I accept the terms in the License Agreement and press "Next" in the following screen:
![Output](../_images/mongo/mongo-step2.png)
-
Choose setup type Complete, then press Next in the following screen:
![Output](../_images/mongo/mongo-step3.png)
-
Install MongoD as a Service, Choose Run Service as Network Service user, then press Next in the following screen:
![Output](../_images/mongo/mongo-step4.png)
-
Install MongoDB Compass, that is the official graphical user interface for MongoDB, Make sure that Install MongoDB Compass is checked, then press Next in the following screen:
![Output](../_images/mongo/mongo-step5.png)
-
Finally, press on Install in the following screen and MongoDB will start the installation
![Output](../_images/mongo/mongo-step6.png)
CRUD with Mongo NoSQL DB
In this section, 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.
-
Open MongoDB Compass, and you should see the following screen:
![Output](../_images/mongo/mongodb-compass-startup-screen.png)
-
Create New Connection, in two ways as follows:
-
Paste your connection String (SRV or Standard), then press Connect
-
![Output](../_images/mongo/mongodb-compass-paste-your-connection-string.png)
-
Fill in Connection fields individually, by filling Hostname, port, selecting the authentication and then press on Connect in following screen:
![Output](../_images/mongo/mongodb-compass-fill-in-connection.png)
Database Creation
-
Click Create database in the following screen:
![Output](../_images/mongo/mongodb-compass-create-database.png)
-
Fill in Database Name and Collection Name, then press Create Database in the following screen:
![Output](../_images/mongo/mongodb-compass-fill-in-database.png)
-
In the following screen, you should see the database that you have created in the previous step.
![Output](../_images/mongo/mongodb-compass-created-database.png)
-
Click on the database, you should see the following screen with the collection that you named in the previous step:
![Output](../_images/mongo/mongodb-compass-collections.png)
-
Click on the collection, you should see the following screen:
![Output](../_images/mongo/mongodb-compass-collection-add-data.png)
Add Document
-
Add data, in the following screen press "Add Data", in two ways Import file or Insert Document
![Output](../_images/mongo/mongodb-compass-add-data.png)
-
Import File, by browsing the file you want to import and selecting Input Type File, then press IMPORT and the data will be imported
![Output](../_images/mongo/mongodb-compass-import-file.png)
-
Insert Document, then fill the data and then press INSERT
![Output](../_images/mongo/mongodb-compass-insert-document.png)
Edit Document
-
To 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:
![Output](../_images/mongo/mongodb-compass-edit-data.png)
![Output](../_images/mongo/mongodb-compass-document-modified.png)
Document Deletion
To delete a Document, hover over the document that you want to delete and press Delete Document and then press DELETE
![Output](../_images/mongo/mongodb-compass-delete-document.png)
![Output](../_images/mongo/mongodb-compass-delete.png)