← MongoDB learning path
MongoDB · Module 2 of 10

CRUD operations

Create, read, update and delete documents.

📖 Key ideas

  1. insertOne({ name: "Asha", age: 21 }) and insertMany([...]).
  2. find({ age: 21 }) and findOne({ name: "Asha" }).
  3. updateOne(filter, { $set: { age: 22 } }).
  4. deleteOne(filter) and deleteMany(filter).
  5. 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