So there I was, innocently sipping chai â when I thought: âHey, letâs play around with MongoDB Atlas. How hard could it be?â Spoiler alert: it was part comedy, part tragedy, but in the endâsuccess tasted sweeter than Gulab Jamun. đŻ
Step 1: Logging into MongoDB Atlas
MongoDB Atlas greeted me like a strict professor: âWelcome, young padawan. Ready to suffer with connection strings?â
I bravely clicked Create Cluster, gave it a free-tier hug, and promised not to blow up the cloud.
Step 2: Building the yelp_demo.reviews Collection
I created a database called yelp_demo and a collection named reviews. Then came the fun partâmanually inserting 10 reviews. Imagine me, typing fake reviews like:
{
"business_id": "B003",
"review": "The biryani here is sooo good!",
"rating": 5,
"date": "2025-08-20"
}
Yes, I felt like an undercover Yelp critic.
Step 3: Query Magic đȘ
Top 5 businesses with highest average rating
Using the Aggregation Pipeline:
_db.reviews.aggregate([
{ $group: { _id: "$business_id", avgRating: { $avg: "$rating" } } },
{ $sort: { avgRating: -1 } },
{ $limit: 5 }
])
_
Translation: âDear MongoDB, please rank these food joints before my stomach makes decisions for me.â
Count reviews containing âgoodâ
But first, MongoDB whispered: âThou shall create a text index.â
db.reviews.createIndex({ review: "text" })
db.reviews.countDocuments({ $text: { $search: "good" } })
Result: Apparently, everyone thinks food is âgood.â My dataset looked like it was sponsored by the word âgood.â đ
Get all reviews for a specific business (B003)
db.reviews.find({ business_id: "B003" }).sort({ date: -1 })
Yup, sorted by date, because reviews age faster than bananas. đ
Update a review
_
db.reviews.updateOne(
{ business_id: "B003" },
{ $set: { review: "Actually, the biryani was legendary!" } }
)
_
Because sometimes, you realize you were too harsh.
Delete a record
db.reviews.deleteOne({ business_id: "B010" })
Farewell, random fake café. You shall not be missed.
Step 4: The Export Saga đ
I thought: âCool, Iâll just click Export in Atlas!â But Atlas laughed in my faceâno export button in browser!
So hereâs the trick I used:
Switch to JSON view in Atlas, copy everything, paste into VS Code, save as .json.
If CSV was needed, I tossed the JSON into an online converter.
Not elegant, but heyâit worked! đ
The Moral of the Story đ§
MongoDB Atlas is like a desi auntie at a weddingâconfusing at first, but once you understand her, sheâll feed you endless data love. I inserted, queried, updated, deleted, and even counted âgoodâ vibes, all while laughing at my own mistakes.
So, if youâre diving into #DataEngineering or #DataAnalysis, donât be afraid to get your hands messy. MongoDB will test your patience, but trust me, the JSON rewards are worth it.
_
_#Hashtags:
Top comments (0)