To keep this reference handy on your desktop, you can save this page as a PDF. Simply press (Windows) or Cmd+P (Mac) and select "Save as PDF" in your browser settings.
db.collection.createIndex({ title: "text" }) : Create a text index for searching words. mongodb cheat sheet pdf download
db.collection.updateMany({}, { $inc: { views: 1 } }) : Increment a value for all documents. $push : Add an item to an array. $unset : Remove a specific field. db.collection.deleteOne({ _id: 1 }) : Delete one document. To keep this reference handy on your desktop,
db.collection.find({ age: 25 }) : Find documents where age is 25. db.collection.findOne() : Return the first document found. .pretty() : Format the output for better readability. .limit(5) : Limit results to 5 documents. $project : Reshapes documents (adds/removes fields).
Create, Read, Update, and Delete are the core of any database interaction. Create (Insert)
Aggregation is used for processing data records and returning computed results. $match : Filters documents (like find ). $group : Groups documents by a specific key. $project : Reshapes documents (adds/removes fields).