CodeToLive

MongoDB Atlas

Use MongoDB's fully-managed cloud database service.

Getting Started

  1. Sign up at mongodb.com/atlas
  2. Create a new project and organization
  3. Deploy a cluster (select tier, cloud provider, region)
  4. Set up database users and IP whitelisting
  5. Connect using the connection string

Cluster Tiers

Tier Best For Features
Free (M0) Learning & small apps 512MB storage, shared RAM
Shared (M2/M5) Small production 5-20GB storage, dedicated RAM
Dedicated (M10+) Production workloads Vertical scaling, advanced features

Atlas Features

  • Atlas Search: Full-text search capabilities
  • Data Lake: Query across Atlas and S3 data
  • Charts: Built-in data visualization
  • Triggers: Serverless functions
  • Backup: Point-in-time recovery
  • Monitoring: Performance metrics and alerts

Connecting to Atlas

// Node.js connection example
const { MongoClient } = require('mongodb');

const uri = "mongodb+srv://username:password@cluster0.mongodb.net/test?retryWrites=true&w=majority";

const client = new MongoClient(uri);

async function run() {
    try {
        await client.connect();
        const db = client.db("sample_db");
        // Work with your database
    } finally {
        await client.close();
    }
}
← Back to Tutorials