DEV Community

Rittwick Bhabak
Rittwick Bhabak

Posted on

1 Introduction

MongoDB is a NoSQL database solution.

1. Installing MongoDB

Install mongodb from mongodb.com
during installation the custom option and service option was selected in windows machine.
A data folder have to be created to store the data
In my windows machine I've created C:\data\db
The bin folder address is added to my environment variables

2. Running MongoDB

Command to stop the automatically running mongodb server net stop MongoDB
Then running the mongodb server mongod --dbpath "C:\data\db"
On another terminal start mongodb shell mongo

3. Some Operations

Viewing all the databases show dbs

Creating & connecting (if not exist) OR connecting (if exists) use shop 'shop' is my database name.

Inserting one data in the collection named products is db.products.insertOne( { name: "A book", price: 12.99 } )
The products collection will be created if it not exists.

Retrieving all the data of a collection db.products.find()
To get a prettier output db.products.find().pretty()

4. Few Stories Behind the scene

These are the layers of the big picture.
Previous layer communicate with the next next layer and thus the flow goes from Frontend to Database.

  • Front-end UI
  • Backend(server) Drivers(eg. nodejs, python, java) MongoDB Shell
  • MongoDB Server
  • Storage Engine
  • Database

N.B: storage engine read and write data in two places.
Database - in this case process is slow
Memory - in this case the process is fast

Top comments (0)