In this article, we will learn about the data types and their usage in MongoDB. If you are new to MongoDB then I would recommend you to go through the previous article of the series:
- Part 1 — Getting started with MongoDB
- Part 2 — Configure a Windows Service for MongoDB
- Part 3 — Working with Database in MongoDB
As we already know, MongoDB stores data in BSON format. BSON stands for the Binary-encoded format of JSON. Using BSON, we can make remote procedure calls in MongoDB.
In MongoDB, each data type has an alias as well as a number which can be used for finding or searching the record in MongoDB. We will also learn about How to use that number/alias in searching in this article. We will use find () method which is used to select the document in the collection and is similar to the “Select” keyword used in SQL and another method is pretty () which makes easier to read the output of the document. Data types in MongoDB are mentioned below: