MongoDB

MongoDB is a NoSQL database which has a flexible schema, and it stores data in the key- value pairs and in the form of Json or Binary Json format. default port 27017

MongoDB is support for inbuild scaling and sharding and we use shard key and sort key.

it has primary index, Secondary Key (for ascending or descending order) and compound index (for ascending order and descending order)

Multikey index: it uses for the array of the field

Text Index: A Text Index is used in MongoDB to enable full-text search capabilities and It allows you to search for words or phrases in string fields.

Geospatial Index: For storing and querying geographical coordinates, useful for location-based queries.

In MongoDB uses caching layer which can significantly enhance read performance by temporarily storing frequently accessed data in a cache layer

MongoDB supports ACID transactions starting from version 4.0. Transactions ensure a series of operations are executed atomically, even across multiple documents or collections.

MongoDB use Btree as data structures to store the data in disk.

It has a storage engine is wiredTiger

→ It has a document-level locks

→ data compression and encryption.

→ it uses WAL (write Ahead Log) to improve the performance and efficiency this uses for durability and crash-recover.

The Aggregation Framework in MongoDB is a powerful feature designed to process and analyze data in a flexible and efficient manner. It allows you to perform operations on your data to transform it into meaningful insights or summarized information.

Common Stages in the Aggregation Pipeline

  1. $match: Filters documents based on specified criteria (similar to find()).

  2. $group: Groups documents by a specified field and performs aggregation operations (e.g., sum, average).

  3. $sort: Sorts documents based on specified fields.

  4. $project: Reshapes documents by including or excluding fields or adding new computed fields.

  5. $limit: Restricts the number of documents passed to the next stage.

  6. $skip: Skips a specified number of documents and passes the rest to the next stage.

  7. $unwind: Deconstructs an array field from the input documents to output a document for each element.