Loading

Quipoin Menu

Learn • Practice • Grow

mongodb / Insert Operations
mcq
Direction: Choose the correct option

Q1.

Which method inserts a single document into a collection?
A. db.collection.insert()
B. db.collection.insertOne()
C. db.collection.addOne()
D. db.collection.saveOne()
Direction: Choose the correct option

Q2.

How do you insert multiple documents at once?
A. db.collection.insertAll()
B. db.collection.insertMany()
C. db.collection.insertMultiple()
D. db.collection.addMany()
Direction: Choose the correct option

Q3.

What does `db.collection.insertOne()` return?
A. The inserted document
B. A boolean
C. The number of documents inserted
D. A result object with `acknowledged` and `insertedId`
Direction: Choose the correct option

Q4.

What happens if you try to insert a document without an `_id` field?
A. MongoDB automatically generates an `_id` of type ObjectId
B. An error is thrown
C. `_id` is set to null
D. The operation fails
Direction: Choose the correct option

Q5.

Given `db.users.insertMany([{name: 'Alice'}, {name: 'Bob'}])`, how many documents are inserted?
A. It depends
B. 2
C. 0
D. 1