Insert Documents in MongoDB

From the MongoDB cheat sheet · CRUD Operations · verified Jul 2026

Insert Documents

Add new documents to a collection

javascript
// Insert one document
db.users.insertOne({
  name: "John Doe",
  email: "john@example.com",
  age: 30,
  created: new Date()
})

// Insert multiple documents
db.users.insertMany([
  { name: "Alice", age: 25 },
  { name: "Bob", age: 35 }
])
🟢 Essential - Every MongoDB app needs insert operations
💡 MongoDB automatically adds _id if not provided
⚡ insertMany() is faster than multiple insertOne()
📌 Returns insertedId(s) for tracking
⚠️ Check writeConcern for production apps
crudinsert

More MongoDB tasks

Back to the full MongoDB cheat sheet