⏱️3 min read · 466 words
MongoDB হল বিশ্বের সবচেয়ে জনপ্রিয় NoSQL ডাটাবেস। 2026 সালে, MongoDB 8.0 প্রধান কর্মক্ষমতা উন্নতি এবং উন্নত ডেভেলপার টুল নিয়ে আসে। এই সম্পূর্ণ নির্দেশিকাটি আপনার প্রথম নথি থেকে উৎপাদন-গ্রেড MongoDB আর্কিটেকচার পর্যন্ত সবকিছুই কভার করে।
📋 Table of Contents
কেন MongoDB?
- নমনীয় স্কিমা— বিকশিত ডেটা মডেলের জন্য কোন স্থানান্তর নেই
- JSON-এর মতো নথি— জাভাস্ক্রিপ্ট/পাইথন API-এর জন্য প্রাকৃতিক ফিট
- অনুভূমিক স্কেলিং– বিশাল ডেটার জন্য অন্তর্নির্মিত শার্ডিং
- সমৃদ্ধ ক্যোয়ারী ভাষা— অ্যাগ্রিগেশন পাইপলাইন বিশ্লেষণের জন্য SQL-এর প্রতিদ্বন্দ্বী
- অ্যাটলাস ভেক্টর অনুসন্ধান— এআই অ্যাপ্লিকেশনের জন্য শব্দার্থিক অনুসন্ধান
ইনস্টলেশন
# macOS
brew tap mongodb/brew && brew install mongodb-community@8.0
brew services start mongodb-community@8.0
# Ubuntu 24.04
curl -fsSL https://www.mongodb.org/static/pgp/server-8.0.asc | sudo gpg -o /usr/share/keyrings/mongodb-server-8.0.gpg --dearmor
echo "deb [ signed-by=/usr/share/keyrings/mongodb-server-8.0.gpg ] https://repo.mongodb.org/apt/ubuntu noble/mongodb-org/8.0 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-8.0.list
sudo apt update && sudo apt install -y mongodb-org
sudo systemctl start mongod
# Connect to shell
mongosh
কোর CRUD অপারেশন
// Switch database
use techpulse_db
// INSERT
db.users.insertOne({
name: "Alice",
email: "alice@example.com",
skills: ["Python", "React"],
createdAt: new Date()
})
db.posts.insertMany([
{ title: "React Guide", views: 1500, tags: ["react", "js"] },
{ title: "Python Guide", views: 2300, tags: ["python", "backend"] }
])
// FIND
db.users.find({ skills: "Python" }) // match array element
db.posts.find(
{ views: { $gt: 1000 } }, // filter
{ title: 1, views: 1, _id: 0 } // projection
)
// UPDATE
db.users.updateOne(
{ email: "alice@example.com" },
{ $set: { role: "senior" }, $push: { skills: "Go" } }
)
db.posts.updateMany(
{ tags: "python" },
{ $inc: { views: 100 } }
)
// DELETE
db.users.deleteOne({ email: "alice@example.com" })
কর্মক্ষমতা জন্য সূচক
// Check slow queries
db.posts.find({ title: "React Guide" }).explain("executionStats")
// Create indexes
db.users.createIndex({ email: 1 }, { unique: true })
db.posts.createIndex({ tags: 1, views: -1 }) // compound
db.articles.createIndex({ title: "text" }) // full-text search
db.events.createIndex({ createdAt: 1 },
{ expireAfterSeconds: 2592000 }) // TTL: 30 days
// Always create indexes before going to production
db.users.getIndexes()
সমষ্টি পাইপলাইন
// Sales report: revenue by category
db.orders.aggregate([
{ $match: { status: "completed", createdAt: { $gte: new Date("2026-01-01") } } },
{ $unwind: "$items" },
{ $group: {
_id: "$items.category",
totalRevenue: { $sum: { $multiply: ["$items.price", "$items.qty"] } },
count: { $sum: 1 }
}},
{ $sort: { totalRevenue: -1 } },
{ $limit: 10 },
{ $project: { category: "$_id", revenue: { $round: ["$totalRevenue", 2] }, _id: 0 }}
])
PyMongo এবং মোটর সহ পাইথন (Async)
from pymongo import MongoClient, ASCENDING
from datetime import datetime
# Sync
client = MongoClient("mongodb://localhost:27017/")
db = client.techpulse_db
users = db.users
result = users.insert_one({"name": "Alice", "createdAt": datetime.utcnow()})
alice = users.find_one({"name": "Alice"}, {"_id": 0})
users.update_one({"name": "Alice"}, {"$set": {"active": True}})
# Async with Motor (for FastAPI)
import motor.motor_asyncio
async_client = motor.motor_asyncio.AsyncIOMotorClient("mongodb://localhost:27017")
async_db = async_client.techpulse_db
async def create_user(data: dict) -> str:
result = await async_db.users.insert_one(data)
return str(result.inserted_id)
async def list_users(page: int = 1) -> list:
cursor = async_db.users.find().skip((page-1)*20).limit(20)
return await cursor.to_list(length=20)
ডেটা মডেলিং: এম্বেড বনাম রেফারেন্স
// Embed when reading together (1-to-few)
{
_id: ObjectId("..."),
title: "MongoDB Guide",
author: { name: "Alice", email: "alice@blog.com" }, // embedded
tags: ["mongodb", "nosql"] // embedded
}
// Reference when shared/large (1-to-many)
// posts: { authorId: ObjectId("user1") }
// Look up with $lookup
db.posts.aggregate([
{ $lookup: {
from: "users",
localField: "authorId",
foreignField: "_id",
as: "author"
}},
{ $unwind: "$author" }
])
উৎপাদনের সর্বোত্তম অভ্যাস
- রেপ্লিকা সেট ব্যবহার করুন— HA এর জন্য সর্বনিম্ন 3টি নোড
- প্রমাণীকরণ সক্ষম করুন— প্রমাণীকরণ ছাড়া MongoDB চালাবেন না
- নথি যাচাই করুন— JSON স্কিমা বা Pydantic ব্যবহার করুন
- ধীরগতির প্রশ্নগুলি মনিটর করুন– প্রোফাইলার সক্ষম করুন, অ্যাটলাস পর্যবেক্ষণ ব্যবহার করুন
- নথির আকার সীমিত করুন– 16MB BSON সীমার মধ্যে ভাল থাকুন
- উৎপাদনের জন্য অ্যাটলাস– ব্যাকআপ, স্কেলিং, পর্যবেক্ষণ সহ পরিচালিত পরিষেবা
# Atlas connection
MONGO_URI = "mongodb+srv://user:pass@cluster.mongodb.net/mydb?retryWrites=true&w=majority"
client = MongoClient(MONGO_URI)
2026 সালে MongoDB 8.0 হল নমনীয়, দ্রুত অ্যাপ্লিকেশনের জন্য সেরা নথি ডাটাবেস। সহজভাবে শুরু করুন, সঠিক সূচক তৈরি করুন এবং বিশ্লেষণের জন্য একত্রিতকরণ পাইপলাইন ব্যবহার করুন। আপনার অ্যাপ্লিকেশানগুলিতে AI-চালিত শব্দার্থিক অনুসন্ধানের জন্য Atlas Vector অনুসন্ধানের সাথে যুক্ত করুন৷
🔗 Share this article
✍️ Leave a Comment