Install MongoDB, understand the document model, and perform all four CRUD operations from the shell and from Node.js.
MongoDB stores data as BSON (Binary JSON) documents. A document is like a row in SQL — but it can have nested objects and arrays. No fixed schema required.
# Mac: brew install mongodb-community
# Linux: see mongodb.com/docs/manual/installation
# Or use MongoDB Atlas free tier (cloud)
# Start the shell
mongosh// Select database (creates if doesn't exist)
use myapp
// INSERT
db.users.insertOne({ name: 'Alice', age: 28, role: 'admin' })
db.users.insertMany([
{ name: 'Bob', age: 32 },
{ name: 'Carol', age: 25 }
])
// FIND
db.users.find() // all documents
db.users.findOne({ name: 'Alice' })
db.users.find({ age: { $gte: 28 } }) // age >= 28
// UPDATE
db.users.updateOne(
{ name: 'Alice' },
{ $set: { role: 'superadmin' } }
)
// DELETE
db.users.deleteOne({ name: 'Carol' })
db.users.deleteMany({ age: { $lt: 18 } })_id field automatically. It's a 12-byte ObjectId that encodes a timestamp. You can use it to sort documents by creation time without storing a separate createdAt field: .sort({ _id: -1 }).insertOne, insertMany, find, findOne, updateOne, deleteOne — the core operations._id ObjectId.