4 min read
•Question 23 of 27easyWhat is MongoDB Atlas?
MongoDB cloud database service.
What You'll Learn
- What Atlas is
- Key features
- Getting started
What is MongoDB Atlas?
MongoDB Atlas is a fully managed cloud database service that handles deployment, scaling, and maintenance.
Key Features
- Multi-cloud: AWS, GCP, Azure
- Auto-scaling: Adjusts resources automatically
- Backups: Continuous with point-in-time recovery
- Security: Encryption, VPC peering, IP whitelisting
- Monitoring: Built-in performance insights
Getting Started
code.jsJavaScript
// 1. Create cluster on atlas.mongodb.com
// 2. Get connection string
// 3. Connect
const mongoose = require('mongoose');
mongoose.connect(
'mongodb+srv://user:password@cluster.mongodb.net/mydb?retryWrites=true&w=majority'
);Tiers
| Tier | Use Case |
|---|---|
| M0 (Free) | Learning, small projects |
| M2/M5 | Development |
| M10+ | Production |
| Serverless | Variable workloads |
Atlas Search
code.jsJavaScript
// Full-text search with Atlas Search
db.movies.aggregate([
{
$search: {
index: "default",
text: {
query: "adventure",
path: "title"
}
}
}
]);Data API
code.jsJavaScript
// REST API access to your data
fetch('https://data.mongodb-api.com/app/data-xxx/endpoint/data/v1/action/findOne', {
method: 'POST',
headers: {
'api-key': 'YOUR_API_KEY',
'Content-Type': 'application/json'
},
body: JSON.stringify({
dataSource: 'Cluster0',
database: 'mydb',
collection: 'users',
filter: { email: 'john@example.com' }
})
});