Tutorials Logic, IN +91 8092939553 info@tutorialslogic.com
FAQs Support
Navigation
Home About Us Contact Us Blogs FAQs
Tutorials
All Tutorials
Services
Academic Projects Resume Writing Interview Questions Website Development
Compiler Tutorials

MongoDB Atlas

What is MongoDB Atlas?

MongoDB Atlas is the fully managed cloud database service built by MongoDB. It handles provisioning, patching, backups, monitoring, and scaling automatically — so you can focus on building your application. Atlas runs on AWS, Google Cloud, and Azure, and offers a free tier (M0) with 512MB storage and no credit card required.

Atlas Features Overview

FeatureDescription
Atlas ClustersManaged MongoDB replica sets on AWS, GCP, or Azure
Atlas SearchFull-text search powered by Apache Lucene, integrated with MongoDB
Atlas Data APIRESTful HTTP API to read/write data without a driver
Atlas TriggersRun serverless functions in response to database events
Atlas ChartsBuilt-in data visualization and dashboards
Atlas Device SyncSync data between mobile devices and the cloud
Atlas Vector SearchSemantic search using vector embeddings for AI applications
BackupsContinuous backups with point-in-time restore

Connection Strings

Atlas Connection String Formats
// Standard connection string (SRV format — recommended)
mongodb+srv://username:password@cluster0.abc123.mongodb.net/myDatabase

// Standard connection string (non-SRV)
mongodb://username:password@cluster0-shard-00-00.abc123.mongodb.net:27017,
  cluster0-shard-00-01.abc123.mongodb.net:27017,
  cluster0-shard-00-02.abc123.mongodb.net:27017/myDatabase?ssl=true&replicaSet=atlas-xyz&authSource=admin

// Connect with mongosh
mongosh "mongodb+srv://username:password@cluster0.abc123.mongodb.net/myDatabase"

// Connection string with options
mongodb+srv://username:password@cluster0.abc123.mongodb.net/myDatabase?retryWrites=true&w=majority
Connecting from Node.js
// Install the MongoDB Node.js driver
// npm install mongodb

const { MongoClient, ServerApiVersion } = require("mongodb")

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

const client = new MongoClient(uri, {
  serverApi: {
    version: ServerApiVersion.v1,
    strict: true,
    deprecationErrors: true
  }
})

async function run() {
  try {
    await client.connect()
    await client.db("admin").command({ ping: 1 })
    console.log("Connected to MongoDB Atlas!")

    const db = client.db("myapp")
    const users = db.collection("users")

    // Insert a document
    const result = await users.insertOne({ name: "Alice", email: "alice@example.com" })
    console.log("Inserted:", result.insertedId)

    // Find documents
    const allUsers = await users.find({}).toArray()
    console.log("Users:", allUsers)

  } finally {
    await client.close()
  }
}

run().catch(console.dir)
Connecting from Python
// Install PyMongo: pip install pymongo

// Python connection example
from pymongo import MongoClient
from pymongo.server_api import ServerApi

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

client = MongoClient(uri, server_api=ServerApi("1"))

try:
    client.admin.command("ping")
    print("Connected to MongoDB Atlas!")

    db = client["myapp"]
    users = db["users"]

    # Insert a document
    result = users.insert_one({"name": "Alice", "email": "alice@example.com"})
    print("Inserted:", result.inserted_id)

    # Find documents
    for user in users.find({"active": True}):
        print(user)

finally:
    client.close()

Ready to Level Up Your Skills?

Explore 500+ free tutorials across 20+ languages and frameworks.