← MongoDB learning pathMongoDB · Module 2 of 10
CRUD operations
Create, read, update and delete documents.
📖 Key ideas
- insertOne({ name: "Asha", age: 21 }) and insertMany([...]).
- find({ age: 21 }) and findOne({ name: "Asha" }).
- updateOne(filter, { $set: { age: 22 } }).
- deleteOne(filter) and deleteMany(filter).
- Projection chooses fields: find({}, { name: 1, _id: 0 }).
💡 Real-life example: CRUD is the four basic kitchen jobs: add (create), taste (read), adjust (update), throw away (delete).
insertOneAdds one document
findReads matching documents
$setSets field values
ProjectionSelects returned fields