MongoDB stores JSON documents without rigid schemas. Atlas free tier gives you a cloud cluster with 512MB storage, backups, and monitoring — no credit card required.
When to Use MongoDB
Your data doesn't fit neatly into tables. User profiles have optional fields. Products have different attributes. Content has nested structures.
MongoDB: store documents as they are. No migrations for new fields. Schema evolves with your app.
What You Get for Free
Atlas Free Tier (M0):
- 512MB storage
- Shared cluster (AWS, GCP, or Azure)
- Automated backups
- Monitoring dashboard
- No credit card
Core features:
// Insert
await db.collection('users').insertOne({
name: 'Alice',
email: 'alice@test.com',
preferences: { theme: 'dark', language: 'en' },
tags: ['developer', 'gamer']
});
// Query
const users = await db.collection('users')
.find({ tags: 'developer', 'preferences.theme': 'dark' })
.sort({ name: 1 })
.limit(10)
.toArray();
// Aggregation pipeline
const stats = await db.collection('orders').aggregate([
{ $match: { status: 'completed' } },
{ $group: { _id: '$category', total: { $sum: '$amount' }, count: { $sum: 1 } } },
{ $sort: { total: -1 } }
]).toArray();
Flexible schema — add fields anytime without migrations
Rich queries — nested object queries, array queries, regex, geo-spatial
Aggregation pipeline — powerful data transformation and analytics
Change streams — real-time notifications on data changes
Full-text search — Atlas Search (Lucene-based)
Transactions — multi-document ACID transactions
Quick Start
npm i mongodb
import { MongoClient } from 'mongodb';
const client = new MongoClient('mongodb+srv://...');
const db = client.db('myapp');
// Ready to use — no schema definition, no migrations
await db.collection('users').insertOne({ name: 'Bob' });
With Mongoose (ODM)
import mongoose from 'mongoose';
const userSchema = new mongoose.Schema({
name: { type: String, required: true },
email: { type: String, unique: true },
createdAt: { type: Date, default: Date.now },
});
const User = mongoose.model('User', userSchema);
const user = await User.create({ name: 'Alice', email: 'alice@test.com' });
If your data has varying structures and you want to ship fast — MongoDB gets out of your way.
Need web scraping or data extraction? Check out my tools on Apify — get structured data from any website in minutes.
Custom solution? Email spinov001@gmail.com — quote in 2 hours.
Top comments (0)