Popular Categories

Demystifying: MongoDB

MongoDB is an open-source document database and leading NoSQL database. MongoDB is written in C++. It is a cross-platform, document oriented database that provides, high performance, high availability, and easy scalability. MongoDB works on concept of collection and document.

Prerequisites:

Before proceeding make sure you should have basic understanding of database (Specially RDBMS).

1. Basic Concepts:

  1. Database: Database is a physical container for collections.
  2. Collection (Like a Table in RDBMS): Collection is a group of MongoDB documents. In short a single collection can have multiple documents. A collection may store documents those who are not same in structure. This is possible because MongoDB is a Schema-Less database. In a relational database like MySQL, a schema defines the organization / structure of data in a database.
  3. Document (Like a record of an RDBMS): A document is the unit of storing data in a MongoDB database. It uses JSON style for storing data. Often, the term “object” is used to refer a document.

RDBMS to MongoDB Mapping Chart:

The following table shows the relationship of RDBMS terminology with MongoDB.

RDMBS MongoDB
DatabaseDatabase
TableCollection
RowDocument
columnField
Table JoinEmbedded Documents
Primary Key Primary Key

Why you should prefer MongoDB over RDBMS?

The advantages of NoSQL databases such as Mongodb over RDMBS are no secret, especially when cloud computing has gained wide adoption.
They were created in response to the limitations of traditional relational database technology. When compared against relational databases, NoSQL databases are more scalable and provide superior performance, and their data model addresses several shortcomings of the the relational model.

  1. Schema less − MongoDB is a document database in which one collection holds different documents. Number of fields, content and size of the document can differ from one document to another.
  2. Ease of scale-out − MongoDB is easy to scale (It is horizontally scalable i.e we can add more servers (sharding) but RDBMS is only vertically scalable i.e increasing RAM.)
  3. MongoDB emphasizes on the CAP theorem (Consistency, Availability, and Partition tolerance) but RDBMS emphasizes ACID properties (Atomicity, Consistency, Isolation, and Durability).
  4. Document Oriented Storage − Data is stored in the form of JSON style documents.
  5. Auto-sharding (Sharding is a type of database partitioning that separates very large databases the into smaller, faster, more easily managed parts called data shards.)
  6. Rich queries
  7. No complex joins.
  8. Fast in-place updates

MongoDB: Environment

To setup MongoDB, firstly you need to know your Operating System (i.e Windows/Mac/Ubuntu) and where are you going to install mongo at. In my case i am using Windows and it is 64 – bit

Learn how to detect your windows bit

To download MongoDB visit https://www.mongodb.com/download-center/

Note, you have the option to directly use cloud (a server service provided by MongoDB), but for now we are going to use SERVER option.

How to install MongoDB on Windows 10

Running MondoDB:

  1. After you have setup, start by using command: “mongod” in command prompt.
  2. Now open command prompt again and use “mongo” command to open panel.

Learning Basic MongoDB commands:

Till now i expect you all to have your MongoDB running. We will now be moving ahead and learning through MongoDB commands.

MongoDB Help:
To get a list of commands, type db.help() in MongoDB client.

MongoDB Statistics:
Type the command db.stats() in MongoDB client. This will show the database name, number of collection and documents in the database.

2. Data Modeling:

To understand data modeling difference between RDBMS and MongoDB. Lets take an example, suppose a client needs a database design for his blog. The blog has the following requirements.

  • Every post has the unique title, description and url.
  • Every post can have one or more tags.
  • Every post has the name of its publisher and total number of likes.
  • Every post has comments given by users along with their name, message, data-time and likes.
  • On each post, there can be zero or more comments.

In RDBMS schema, design for above requirements will have minimum three tables. You will have a post table (id, title, description, url, likes, post_by), a comment table (comment_id,post_id,by_user,message,data_time,likes) and tag list table  (id,post_id,tag).

While in MongoDB schema, design will have one collection post and the following structure:

{
   _id: POST_ID
   title: TITLE_OF_POST, 
   description: POST_DESCRIPTION,
   by: POST_BY,
   url: URL_OF_POST,
   tags: [TAG1, TAG2, TAG3],
   likes: TOTAL_LIKES, 
   comments: [	
      {
         user:'COMMENT_BY',
         message: TEXT,
         dateCreated: DATE_TIME,
         like: LIKES 
      },
      {
         user:'COMMENT_BY',
         message: TEXT,
         dateCreated: DATE_TIME,
         like: LIKES
      }
   ]
}

3. MongoDB: Create Database

The use Command: MongoDB use DATABASE_NAME is used to create database. The command will create a new database if it doesn’t exist, otherwise it will return the existing database.

>use mydb
switched to db mydb

Currently Selected Database To check currently selected Database, use the command db

>db
mydb

Show Database List If you want to check your databases list, use the command show dbs.

>show dbs
admin   0.000GB
config  0.000GB
local   0.000GB

4. MongoDB: Drop Database

The db.dropDatabase() command is used to drop a existing database. If you want to delete new database < mydb >, then dropDatabase() command would be as follows:

> use mydb
switched to db mydb
> db.dropDatabase()
{ "ok" : 1 }

Now check list of databases.

> show dbs
local      0.78125GB
test       0.23012GB

 5. MongoDB: Create Collection

The db.createCollection(name, options) is used to create collection. In the command, name is name of collection to be created. Options is a document and is used to specify configuration of collection. From Now onwards we are going to use one database complete example to move ahead with each command.

> use employeeDB
switched to db employeeDB
> db.createCollection("Employee")
{ "ok" : 1 }

You can check the created collection by using the command show collections.

> show collections
Employee

Do Note: In MongoDB, you don’t need to create collection. MongoDB creates collection automatically, when you insert some document.

> db.Employee.insert({"Employeeid" : 1, "EmployeeName" : "Martin"})
> show collections
mycol
mycollection
system.indexes

6. MongoDB: Drop Collection

The db.collection.drop() is used to drop a collection from the database.

> use employeeDB
switched to db employeeDB
> show collections
Employee
> db.employee.drop()
false
> db.Employee.drop()
true

Do Note: Mongo is case senstive. As can be seen in the above example that db.employee.drop() returned false.

 7. MongoDB: Datatypes

MongoDB supports many datatypes. Some of them are:

  • String − This is the most commonly used datatype to store the data. String in MongoDB must be UTF-8 valid.
  • Integer − This type is used to store a numerical value. Integer can be 32 bit or 64 bit depending upon your server.
  • Boolean − This type is used to store a boolean (true/ false) value.
  • Double − This type is used to store floating point values.
  • Min/ Max keys − This type is used to compare a value against the lowest and highest BSON elements.
  • Arrays − This type is used to store arrays or list or multiple values into one key.
  • Timestamp − ctimestamp. This can be handy for recording when a document has been modified or added.
  • Object − This datatype is used for embedded documents.
  • Null − This type is used to store a Null value.
  • Symbol − This datatype is used identically to a string; however, it’s generally reserved for languages that use a specific symbol type.
  • Date − This datatype is used to store the current date or time in UNIX time format. You can specify your own date time by creating object of Date and passing day, month, year into it.
  • Object ID − This datatype is used to store the document’s ID.
  • Binary data − This datatype is used to store binary data.
  • Code − This datatype is used to store JavaScript code into the document.
  • Regular expression − This datatype is used to store regular expression.

8. MongoDB: The Insert() Method

> db.mycol.insert({
   _id: ObjectId(7df78ad8902c),
   title: 'MongoDB Overview', 
   description: 'MongoDB is no sql database',
   by: 'tutorials point',
   url: 'http://www.tutorialspoint.com',
   tags: ['mongodb', 'database', 'NoSQL'],
   likes: 100
})

Add MongoDB Array using insert() with Example

var myEmployee=
	[
	
		{
			"Employeeid" : 1,
			"EmployeeName" : "Smith"
		},
		{
			"Employeeid"   : 2,
			"EmployeeName" : "Mohan"
		},
		{
			"Employeeid"   : 3,
			"EmployeeName" : "Joe"
		},

	];

> db.Employee.insert(myEmployee);

BulkWriteResult({
        "writeErrors" : [ ],
        "writeConcernErrors" : [ ],
        "nInserted" : 3,
        "nUpserted" : 0,
        "nMatched" : 0,
        "nModified" : 0,
        "nRemoved" : 0,
        "upserted" : [ ]
})

What is Primary Key in MongoDB?

In MongoDB, _id field as the primary key for the collection so that each document can be uniquely identified in the collection. The _id field contains a unique ObjectID value. By default when inserting documents in the collection, if you don’t add a field name with the _id in the field name, then MongoDB will automatically add an Object id field as shown below If you want to ensure that MongoDB does not create the _id Field when the collection is created and if you want to specify your own id as the _id of the collection, then you need to explicitly define this while creating the collection. Let’s look at an example on how we can achieve this.

> db.Employee.insert({_id:10, "EmployeeName" : "Smith"})

 

9. MongoDB: Query Document

MongoDB Query Document using find() with Example: The find() Method: will display all the documents in a non-structured way.

> db.Employee.find()

{ "_id" : ObjectId("5c5e61368d1aa1a1d1ac5a67"), "Employeeid" : 1, "EmployeeName" : "Smith" }
{ "_id" : ObjectId("5c5e61368d1aa1a1d1ac5a68"), "Employeeid" : 2, "EmployeeName" : "Mohan" }
{ "_id" : ObjectId("5c5e61368d1aa1a1d1ac5a69"), "Employeeid" : 3, "EmployeeName" : "Joe" }

To display the results in a formatted way, you can use pretty() method.
> db.Employee.find().pretty()

{
        "_id" : ObjectId("5c5e61368d1aa1a1d1ac5a67"),
        "Employeeid" : 1,
        "EmployeeName" : "Smith"
}
{
        "_id" : ObjectId("5c5e61368d1aa1a1d1ac5a68"),
        "Employeeid" : 2,
        "EmployeeName" : "Mohan"
}
{
        "_id" : ObjectId("5c5e61368d1aa1a1d1ac5a69"),
        "Employeeid" : 3,
        "EmployeeName" : "Joe"
}

Note: Apart from find() method, there is findOne() method, that returns only one document. An easier way to play more with queries will be to use RDBMS concept together and have equivalent Mongo Query written:

1. Equality: Find an Employee whose name is “Smith” in the collection

> db.Employee.find({"EmployeeName":"Smith"})
{ "_id" : ObjectId("5c5e61368d1aa1a1d1ac5a67"), "Employeeid" : 1, "EmployeeName" : "Smith" }

Note: you can use pretty to get the results in proper format: db.Employee.find({“EmployeeName”:”Smith”}).pretty()

2. Less Than: Find all employees whose Employeeid is less than 3

> db.Employee.find({"Employeeid":{$lt:3}})
{ "_id" : ObjectId("5c5e61368d1aa1a1d1ac5a67"), "Employeeid" : 1, "EmployeeName" : "Smith" }
{ "_id" : ObjectId("5c5e61368d1aa1a1d1ac5a68"), "Employeeid" : 2, "EmployeeName" : "Mohan" }	

3. Greater Than: Find all employees whose Employeeid is greater than 2

> db.Employee.find({"Employeeid":{$gt:2}})
{ "_id" : ObjectId("5c5e61368d1aa1a1d1ac5a69"), "Employeeid" : 3, "EmployeeName" : "Joe" }

4. Less Than Equals: Find all employees whose Employeeid is less than equal to 2

> db.Employee.find({"Employeeid":{$lte:2}})
{ "_id" : ObjectId("5c5e61368d1aa1a1d1ac5a67"), "Employeeid" : 1, "EmployeeName" : "Smith" }
{ "_id" : ObjectId("5c5e61368d1aa1a1d1ac5a68"), "Employeeid" : 2, "EmployeeName" : "Mohan" }

5. Greater Than Equals: Find all employees whose Employeeid is greater than equal to 2

> db.Employee.find({"Employeeid":{$gte:2}})
{ "_id" : ObjectId("5c5e61368d1aa1a1d1ac5a68"), "Employeeid" : 2, "EmployeeName" : "Mohan" }
{ "_id" : ObjectId("5c5e61368d1aa1a1d1ac5a69"), "Employeeid" : 3, "EmployeeName" : "Joe" }

6. Not Equals: Find all employees whose Employeeid is not equal to 2

> db.Employee.find({"Employeeid":{$ne:2}})
{ "_id" : ObjectId("5c5e61368d1aa1a1d1ac5a67"), "Employeeid" : 1, "EmployeeName" : "Smith" }
{ "_id" : ObjectId("5c5e61368d1aa1a1d1ac5a69"), "Employeeid" : 3, "EmployeeName" : "Joe" }

7. AND in MongoDB: In the find() method, if you pass multiple keys by separating them by ‘,’ then MongoDB treats it as AND condition.

db.MYCOLLECTION_NAME.find(
   {
      $and: [
         {key1: value1}, {key2:value2}
      ]
   }
).pretty()

Lets run a simple example on Employee Collection: Find an Employee whose id is 1 and name is Smith

> db.Employee.find({$and:[{"Employeeid":1},{"EmployeeName": "Smith"}]})
{ "_id" : ObjectId("5c5e61368d1aa1a1d1ac5a67"), "Employeeid" : 1, "EmployeeName" : "Smith" }

8. OR in MongoDB: To query documents based on the OR condition, you need to use $or keyword.

> db.MYCOLLECTION_NAME.find(
   {
      $or: [
         {key1: value1}, {key2:value2}
      ]
   }
).pretty()

Lets run a simple example on Employee Collection:

Find an Employee whose id is 1 or name is Joe

> db.Employee.find({$or:[{"Employeeid":1},{"EmployeeName": "Joe"}]})
{ "_id" : ObjectId("5c5e61368d1aa1a1d1ac5a67"), "Employeeid" : 1, "EmployeeName" : "Smith" }
{ "_id" : ObjectId("5c5e61368d1aa1a1d1ac5a69"), "Employeeid" : 3, "EmployeeName" : "Joe" }

8. Using AND and OR Together: Find Employee Record whose id is greater than 1 AND whose Name is either Mohan or Joe

> db.Employee.find({"Employeeid": {$gt:1}, $or:[{"EmployeeName":"Joe"},{"EmployeeName": "Mohan"}]})
{ "_id" : ObjectId("5c5e61368d1aa1a1d1ac5a68"), "Employeeid" : 2, "EmployeeName" : "Mohan" }
{ "_id" : ObjectId("5c5e61368d1aa1a1d1ac5a69"), "Employeeid" : 3, "EmployeeName" : "Joe" }

 

10. MongoDB: The Update() Method

The basic syntax of update() method is as follows:

db.COLLECTION_NAME.update(SELECTION_CRITERIA, UPDATED_DATA)

Lets use an example to understand: a. Fetch all records and update employee name to Smith Doe where employee name is smith

> db.Employee.find()
{ "_id" : ObjectId("5c5e61368d1aa1a1d1ac5a67"), "Employeeid" : 1, "EmployeeName" : "Smith" }
{ "_id" : ObjectId("5c5e61368d1aa1a1d1ac5a68"), "Employeeid" : 2, "EmployeeName" : "Mohan" }
{ "_id" : ObjectId("5c5e61368d1aa1a1d1ac5a69"), "Employeeid" : 3, "EmployeeName" : "Joe" }
> db.Employee.update({'EmployeeName':'Smith'}, {$set:{'EmployeeName':'Smith Doe'}})
WriteResult({ "nMatched" : 1, "nUpserted" : 0, "nModified" : 1 })
> db.Employee.find()
{ "_id" : ObjectId("5c5e61368d1aa1a1d1ac5a67"), "Employeeid" : 1, "EmployeeName" : "Smith Doe" }
{ "_id" : ObjectId("5c5e61368d1aa1a1d1ac5a68"), "Employeeid" : 2, "EmployeeName" : "Mohan" }
{ "_id" : ObjectId("5c5e61368d1aa1a1d1ac5a69"), "Employeeid" : 3, "EmployeeName" : "Joe" }

b. Lets revert the above change back and use another example: Update employee name back to Smith where employee id is 1

> db.Employee.update({"Employeeid":1}, {$set:{"EmployeeName":"Smith"}})
WriteResult({ "nMatched" : 1, "nUpserted" : 0, "nModified" : 1 })

 

11. MongoDB: The Remove() Method

MongoDB’s remove() method is used to remove a document from the collection. The basic syntax of remove() method is as follows:

> db.COLLECTION_NAME.remove(DELLETION_CRITTERIA)

Lets use an example to understand: Delete a record from where employee collection where employee is greater than 2

> db.Employee.remove({"Employeeid":{$gt:2}})
WriteResult({ "nRemoved" : 1 })

> db.Employee.find()
{ "_id" : ObjectId("5c5e61368d1aa1a1d1ac5a67"), "Employeeid" : 1, "EmployeeName" : "Smith" }
{ "_id" : ObjectId("5c5e61368d1aa1a1d1ac5a68"), "Employeeid" : 2, "EmployeeName" : "Mohan" }

Lets add the record back so we can continue using the above data.

db.Employee.insert({"Employeeid" : 3, "EmployeeName" : "Joe"})

Remove All Documents If you don’t specify deletion criteria, then MongoDB will delete whole documents from the collection.

db.COLLECTION_NAME.remove()

Lets for now don’t use this command : ) 

 

12. MongoDB: Projection

Projection means selecting only the necessary data rather than selecting whole of the data of a document. The find() Method MongoDB’s find() method, as discussed earlier in MongoDB Query Document accepts second optional parameter that is list of fields that you want to retrieve. In MongoDB, when you execute find() method, then it displays all fields of a document. To limit this, you need to set a list of fields with value 1 or 0. 1 is used to show the field while 0 is used to hide the fields. The basic syntax of find() method with projection is as follows:

> db.COLLECTION_NAME.find(SEARCH_CRITERIA,{KEY1:1,KEY2:1...})

Lets consider back the Employee Collection: 1. Lets first see what we have in our records:

> db.Employee.find()
{ "_id" : ObjectId("5c5e61368d1aa1a1d1ac5a67"), "Employeeid" : 1, "EmployeeName" : "Smith" }
{ "_id" : ObjectId("5c5e61368d1aa1a1d1ac5a68"), "Employeeid" : 2, "EmployeeName" : "Mohan" }
{ "_id" : ObjectId("5c5e6bc88d1aa1a1d1ac5a6a"), "Employeeid" : 3, "EmployeeName" : "Joe" }

Now lets just get the names of Employees

> db.Employee.find({},{"EmployeeName":1})
{ "_id" : ObjectId("5c5e61368d1aa1a1d1ac5a67"), "EmployeeName" : "Smith" }
{ "_id" : ObjectId("5c5e61368d1aa1a1d1ac5a68"), "EmployeeName" : "Mohan" }
{ "_id" : ObjectId("5c5e6bc88d1aa1a1d1ac5a6a"), "EmployeeName" : "Joe" }

If you wish to hide the _id then you will need to specifically mention it with 0. As 0 indicates no need to show the field.

> db.Employee.find({},{"EmployeeName":1,"_id":0})
{ "EmployeeName" : "Smith" }
{ "EmployeeName" : "Mohan" }
{ "EmployeeName" : "Joe" }

> db.Employee.find({},{"EmployeeName":1,"_id":0})

Please note _id field is always displayed while executing find() method, if you don’t want this field, then you need to set it as 0. 2. Find an Employee whose id is 1 or name is Joe and display only Title

> db.Employee.find({$or:[{"Employeeid":1},{"EmployeeName": "Joe"}]},{"EmployeeName":1,"_id":0})
{ "EmployeeName" : "Smith" }
{ "EmployeeName" : "Joe" }

 

13. MongoDB: The Limit() Method

To limit the records in MongoDB, you will need to use limit() method. The basic syntax of limit() method is as follows:

> db.COLLECTION_NAME.find().limit(NUMBER) 

where NUMBER is the number of records you want to display Let say you want to display the 2 records from Employee collection

> db.Employee.find({}).limit(2)
{ "_id" : ObjectId("5c5e61368d1aa1a1d1ac5a67"), "Employeeid" : 1, "EmployeeName" : "Smith" }
{ "_id" : ObjectId("5c5e61368d1aa1a1d1ac5a68"), "Employeeid" : 2, "EmployeeName" : "Mohan" }

 

14. MongoDB: The Skip() Method

Used for skipping the number of documents. The basic syntax of skip() method is as follows:

> db.COLLECTION_NAME.find().limit(NUMBER).skip(NUMBER)

> db.Employee.find({}).limit(2).skip(1)
{ "_id" : ObjectId("5c5e61368d1aa1a1d1ac5a68"), "Employeeid" : 2, "EmployeeName" : "Mohan" }
{ "_id" : ObjectId("5c5e6bc88d1aa1a1d1ac5a6a"), "Employeeid" : 3, "EmployeeName" : "Joe" }

 

15. MongoDB: The Sort() Method

To sort documents in MongoDB, you need to use sort() method. To specify sorting order 1 and -1 are used. 1 is used for ascending order while -1 is used for descending order. The basic syntax of sort() method is as follows:

> db.COLLECTION_NAME.find().sort({KEY:1})

Lets say we want to sort Employee Collection by Employee Name (Ascending order)

> db.Employee.find().sort({"EmployeeName":1})
{ "_id" : ObjectId("5c5e6bc88d1aa1a1d1ac5a6a"), "Employeeid" : 3, "EmployeeName" : "Joe" }
{ "_id" : ObjectId("5c5e61368d1aa1a1d1ac5a68"), "Employeeid" : 2, "EmployeeName" : "Mohan" }
{ "_id" : ObjectId("5c5e61368d1aa1a1d1ac5a67"), "Employeeid" : 1, "EmployeeName" : "Smith" }

 

16. MongoDB: Indexing

Indexes support the efficient resolution of queries. Without indexes, MongoDB must scan every document of a collection to select those documents that match the query statement. This scan is highly inefficient and require MongoDB to process a large volume of data. To create an index you need to use ensureIndex() method of MongoDB. The basic syntax of ensureIndex() method is as follows().

> db.COLLECTION_NAME.ensureIndex({KEY:1}) 

where key is the name of the field on which you want to create index and 1 is for ascending order while -1 for descending order. For example: a. Lets create Index by Employee Id

> db.Employee.ensureIndex({Employeeid:1})
{
        "createdCollectionAutomatically" : false,
        "numIndexesBefore" : 1,
        "numIndexesAfter" : 2,
        "ok" : 1
}

b. Lets create Index by Employee Id and Employee Name

> db.Employee.ensureIndex({"Employeeid":1,"EmployeeName":1})
{
        "createdCollectionAutomatically" : false,
        "numIndexesBefore" : 2,
        "numIndexesAfter" : 3,
        "ok" : 1
}

You can learn more about it at: https://docs.mongodb.com/manual/reference/method/db.collection.ensureIndex

 

17. MongoDB: Aggregation

Aggregations operations process data records and return computed results. The basic syntax of aggregate() method is as follows:

> db.COLLECTION_NAME.aggregate(AGGREGATE_OPERATION)

Lets run an example to understand aggregation concept. Lets first update the existing records and add another set of fields.

> db.Employee.update({'Employeeid':1}, {$set:{'Salary':2000}})
WriteResult({ "nMatched" : 1, "nUpserted" : 0, "nModified" : 1 })
> db.Employee.update({'Employeeid':2}, {$set:{'Salary':2000}})
WriteResult({ "nMatched" : 1, "nUpserted" : 0, "nModified" : 1 })
> db.Employee.update({'Employeeid':3}, {$set:{'Salary':3000}})
WriteResult({ "nMatched" : 1, "nUpserted" : 0, "nModified" : 1 })
> db.Employee.find()
{ "_id" : ObjectId("5c5e61368d1aa1a1d1ac5a67"), "Employeeid" : 1, "EmployeeName" : "Smith", "Salary" : 2000 }
{ "_id" : ObjectId("5c5e61368d1aa1a1d1ac5a68"), "Employeeid" : 2, "EmployeeName" : "Mohan", "Salary" : 2000 }
{ "_id" : ObjectId("5c5e6bc88d1aa1a1d1ac5a6a"), "Employeeid" : 3, "EmployeeName" : "Joe", "Salary" : 3000 }

As can be seen we have another field which is called as Salary. Now let says we want to select salary and their count – example there are 2 employees who have 2000 salary and there is 1 with 3000. How will this be? In RDBMS, it could be something like: Select salary, count(*) from TABLE_NAME group by salary In MongoDB, it would be:

> db.Employee.aggregate([{$group : {_id : "$Salary", Employeeid : {$sum : 1}}}])

when you will run this, it will return:

> db.Employee.aggregate([{$group : {_id : "$Salary", Total_Employee : {$sum : 1}}}])
{ "_id" : 3000, "Total_Employee" : 1 }
{ "_id" : 2000, "Total_Employee" : 2 }

To learn more you can visit: https://docs.mongodb.com/manual/reference/method/db.collection.aggregate/#examples

Recap

To recap you have learned through the following:

  1. Basic concept of MongoDB
  2. Setting up MongoDB Environment
  3. Create Database
  4. Drop Database
  5. Create Collection
  6. Drop Collection
  7. Datatypes
  8. The insert() Method
  9. What is Primary Key in MongoDB?
  10. Query Document
  11. The Update() Method
  12. The Remove() Method
  13. Projection
  14. The Limit() Method
  15. The Skip() Method
  16. The Sort() Method
  17. Indexing
  18. Aggregation

Was this helpful? Did I missed something? Do you have a question? Get in touch.