Data shaped like your objects
MongoDB stores documents — JSON-like objects with nested fields and arrays — in collections. A dish with its tags and ingredients is one document, just like the object in your JavaScript code. No schema is required up front, which makes it popular for fast-moving products.
insertOne and find
db.dishes.insertOne({
name: "Momo",
price: 180,
tags: ["popular", "steamed"],
stock: { qty: 20, unit: "plates" },
});
db.dishes.insertOne({ name: "Masala tea", price: 50, hot: true });
printjson(db.dishes.find().toArray());
print("dishes:", db.dishes.countDocuments());- SQL vs MongoDB: table ↔ collection, row ↔ document, column ↔ field, JOIN ↔ embedding or $lookup.
- On your computer: MongoDB Atlas (free cloud cluster) or a local install, and the mongosh shell.