Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mongodb-preview.mintlify.app/llms.txt

Use this file to discover all available pages before exploring further.

MongoDB stores records as documents inside collections, and collections inside databases. This hierarchy is the foundation for permissions, indexing strategy, and deployment-level organization.

Collections

A collection is a group of documents, similar to a table in relational systems but without fixed row schemas.

When to Use a Collection

Create a separate collection when records:
  • Have different access patterns
  • Need different indexing strategies
  • Have different retention policies
  • Require different permission boundaries

Databases

A database is an administrative container for collections. In practice, teams often segment databases by environment, bounded context, or data residency requirements.

Naming Guidance

  • Keep names descriptive and stable.
  • Avoid sensitive information in names.
  • Align names with service ownership boundaries.

Common Workflows

Select a Database

use appData

Create a Collection Implicitly

MongoDB creates collections on first write:
db.users.insertOne({ email: "alice@example.com", status: "active" })

Create a Collection Explicitly

db.createCollection("events")

Design Recommendations

  • Model for dominant read/write paths first.
  • Keep collection-level indexes intentional and measurable.
  • Define archival and backup expectations per collection class.

Documents

Views

Core Capabilities

Operations and Security