Spinning Up MongoDB on Fedora 26

Here is a script I created to quickly spin up MongoDB.

Notes

By default, MongoDB will store data in /data/db.

The script creates a /data/db directory and configures permissions to allow only the root user and group with read, write and execute (7) permissions. Others have read and execute(5).

I recommended that you tailor permissions to your requirements.

The script then downloads MongoDB (Community Server) to the/tmp directory, unzips and moves the files to a newly created /usr/local/mongodb directory.

After this, the database server is then started.

By default, MongoDB listens on port 27017.

Now open another terminal window and start the shell.

cd /usr/local/mongodb/bin

./mongo

This will connect you to your database server. By default, you will be connected to an empty database called test.

Please note that mongod is what is used to run the database server. mongo is the MongoDB shell which can be used to connect to the database.

 

 

Diary Entry – Wednesday 12/07/2017

8:00am – 9:15am

Continued working through the M001: MongoDB Basics course on MongoDB University. Week 3 material has been released. I have a week to study for the final exam.

10am – 2pm

Continued with M001: MongoDB Basics

Published blog post MongoDB Comparison Query Operators

3:30pm – 4:30pm

Gym – Weight Training

6pm – 9pm

Continued with M001: MongoDB Basics

Published blog post MongoDB Element Query Operators

Logged Diary Entry – Wednesday 12/07/2017

 

MongoDB Element Query Operators

I have been working through the M001: MongoDB Basics course on MongoDB University. Here are some notes on Element Query Operators and my MongoDB Shell and Compass examples.

Descriptions from MongoDB documentation.

Name Description
$exists Matches documents that have the specified field.
$type Selects documents if a field is of the specified type.

Shell Examples

 

Compass Examples

$exists

$type

MongoDB Comparison Query Operators

I have been working through the M001: MongoDB Basics course on MongoDB University. Here are some notes on Comparison Query Operators and my MongoDB Shell and Compass examples.

Descriptions from MongoDB documentation.

Name Description
$eq Matches values that are equal to a specified value.
$gt Matches values that are greater than a specified value.
$gte Matches values that are greater than or equal to a specified value.
$lt Matches values that are less than a specified value.
$lte Matches values that are less than or equal to a specified value.
$ne Matches all values that are not equal to a specified value.
$in Matches any of the values specified in an array.
$nin Matches none of the values specified in an array.

Shell Examples

 

Compass Examples

$eq

$gt

$gte

$lt

$lte

$ne

$in

$nin