1. Insert one
insertOne adds a single document and returns its generated _id.
db.users.insertOne({ name: "Ada", age: 36 })Typorithm · easy
Step 1 of 8 · intro card
CRUD
insertOne adds a single document; insertMany takes an array of documents. MongoDB auto-generates a unique _id for each unless you supply one.
A collection holds documents — JSON-like objects whose fields can be strings, numbers, arrays, or nested objects.
insertOne writes a single document and returns the new _id; insertMany takes an array and writes each element as its own document.
Every document gets a unique _id: an ObjectId by default, or whatever value you set explicitly on the _id field.
insertOne writes one document.
insertMany writes an array of documents.
_id is auto-generated unless supplied.
db.users.insertOne({ name: "Ada", age: 36 })
db.users.insertMany([
{ name: "Linus", age: 54 },
{ name: "Grace", age: 41 },
])Connect each part of the code to the concept before you type.
insertOne adds a single document and returns its generated _id.
db.users.insertOne({ name: "Ada", age: 36 })A document is a JSON-like object; fields can be any BSON type.
{ name: "Ada", age: 36 }insertMany takes an array and inserts each element as its own document.
db.users.insertMany([Each array element becomes one document; each gets its own _id.
{ name: "Linus", age: 54 },Read the concept map and follow the code breakdown.
Type the implementation, repair mistakes and work through every recall exercise.
Use the final check without hints; revisit weak concepts in short practice sessions.