What is MongoDB?

MongoDB is a document database with the scalability and flexibility that you want with the querying and indexing that you need

  • MongoDB stores data in flexible, JSON-like documents, meaning fields can vary from document to document and data structure can be changed over time

  • The document model maps to the objects in your application code, making data easy to work with

  • Ad hoc queries, indexing, and real time aggregation provide powerful ways to access and analyze your data

  • MongoDB is a distributed database at its core, so high availability, horizontal scaling, and geographic distribution are built in and easy to use

  • MongoDB is free and open-source. Versions released prior to October 16, 2018 are published under the AGPL. All versions released after October 16, 2018, including patch fixes for prior versions, are published under the Server Side Public
    License (SSPL) v1
    .

Learn more about how MongoDB works >

Makes development easy

MongoDB’s document model is simple for developers to learn and use, while still providing all the capabilities needed to meet the most complex requirements at any scale. We provide drivers for 10+ languages, and the community has built dozens more.

Connect

View Docs

Here we are connecting to a locally hosted MongoDB database called test with a collection named restaurants.

Insert a document

View Docs

5 example documents are being inserted into the restaurants collection. Each document represents a restuarant with a name, star rating, and categories (stored as an array).

Create a query

View Docs

In this example, we run a simple query to get all of the documents in the restaurants collection and store them as an array.

Build an index

View Docs

Indexes in MongoDB are similar to indexes in other database systems. MongoDB supports indexes on any field or sub-field of a document in a collection. Here, we are building an index on the name field with sort order ascending.

Aggregate

View Docs

Using MongoDB’s aggregation pipeline, you can filter and analyze data based on a given set of criteria. In this example, we pull all the documents in the restaurants collection that have a category of Bakery using the $match operator and then group them by their star rating using the $group operator. Using the accumulator operator, $sum, we can see how many bakeries in our collection have each star rating.

// 1. Connect to MongoDB instance running on localhost
// Connection URL
var url = 'mongodb://localhost:27017/test';

co(function*() {
  const db = yield MongoClient.connect(url);
  console.log("Connected successfully to server");
  
  yield insertDocuments(db, null);
  yield findDocuments(db, null);
  yield indexCollection(db, null);
  yield aggregateDocuments(db, null);

  db.close();
}).catch(err => console.log(err));

MongoDB at scale

40,000,000+
downloads

1,000,000+
MongoDB University students

35,000+
GitHub repos

Need to run MongoDB?

We want to...

  • High availability through built-in replication and failover

  • Horizontal scalability with native sharding

  • End-to-end security

  • Native document validation and schema exploration with Compass

  • Always available global support

  • Management tooling for automation, monitoring, and backup

  • Fully elastic database as a service with built-in best practices

  • High availability through built-in replication and failover

  • Horizontal scalability with native sharding

  • End-to-end security

  • Native document validation and schema exploration with Compass

  • Always available global support

  • Management tooling for automation, monitoring, and backup

  • High availability through built-in replication and failover

  • Horizontal scalability with native sharding

  • End-to-end security

  • Native document validation and schema exploration with Compass

  • Always available global support

  • Fully elastic database as a service with built-in best practices

Trusted by thousands of teams