MongoDB

This section includes tutorials, tips and tricks of using MongoDB

Installation

In this section, we will show you how install MongoDB Community Edition.

  1. Go to https://www.mongodb.com/try/download

  2. Scroll to "MongoDB Community Server", in Available Downloads section, Select the Version, Platform and package and press on Download button

Output
  1. Open the downloaded file, press Next in the following screen:

Output
  1. 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
  1. Choose setup type Complete, then press Next in the following screen:

Output
  1. Install MongoD as a Service, Choose Run Service as Network Service user, then press Next in the following screen:

Output
  1. 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
  1. Finally, press on Install in the following screen and MongoDB will start the installation

Output

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.

  1. Open MongoDB Compass, and you should see the following screen:

Output
  1. Create New Connection, in two ways as follows:

    1. Paste your connection String (SRV or Standard), then press Connect

Output
  1. Fill in Connection fields individually, by filling Hostname, port, selecting the authentication and then press on Connect in following screen:

Output

Database Creation

  1. Click Create database in the following screen:

Output
  1. Fill in Database Name and Collection Name, then press Create Database in the following screen:

Output
  1. In the following screen, you should see the database that you have created in the previous step.

Output
  1. Click on the database, you should see the following screen with the collection that you named in the previous step:

Output
  1. Click on the collection, you should see the following screen:

Output

Add Document

  1. Add data, in the following screen press "Add Data", in two ways Import file or Insert Document

Output
  1. 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
  1. Insert Document, then fill the data and then press INSERT

Output

Edit Document

  1. 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
Output

Document Deletion

To delete a Document, hover over the document that you want to delete and press Delete Document and then press DELETE

Output
Output

Find Document

To 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.

Output

Database Drop

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:

Output
Drop database drops all tables in the database and deletes the database. Be very careful with this statement!