Mid From PDF SQL SQL & Databases

How do you perform CRUD operations in MongoDB?

Create:

db.collection.insertOne({ name: "Alice", age: 25 });

db.collection.insertMany([{ name: "Bob", age: 30 }, { name:

"Charlie", age: 35 }]);

  • Read:

db.collection.find({ age: { $gt: 30 } });

db.collection.findOne({ name: "Alice" });

  • Update:

db.collection.updateOne({ name: "Alice" }, { $set: { age: 26 } });

db.collection.updateMany({ age: { $lt: 30 } }, { $set: { status:

"young" } });

  • Delete:

db.collection.deleteOne({ name: "Alice" });

db.collection.deleteMany({ age: { $lt: 30 } });

More from SQL Server Tutorial

All questions for this course
Toolliyo Assistant
Ask about tutorials, ebooks, training, pricing, mentor services, and support. I use public site content only—not admin or internal tools.

care@toolliyo.com

Need callback? Share your details