0
0
MongoDBquery~5 mins

Insert with arrays in MongoDB - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
What does inserting with arrays mean in MongoDB?
It means adding multiple documents at once by passing an array of objects to the insertMany() method.
Click to reveal answer
beginner
How do you insert multiple documents in MongoDB using an array?
Use the insertMany() method and pass an array of documents as the argument.
Click to reveal answer
beginner
What is the difference between insertOne() and insertMany() in MongoDB?
insertOne() adds a single document, while insertMany() adds multiple documents using an array.
Click to reveal answer
intermediate
Can you insert an empty array of documents in MongoDB?
No, inserting an empty array with insertMany() will not add any documents; the operation succeeds without error.
Click to reveal answer
intermediate
What happens if one document in the array fails to insert in insertMany()?
By default, insertMany() stops and returns an error; you can set ordered:false to continue inserting others.
Click to reveal answer
Which MongoDB method inserts multiple documents at once?
AinsertAll()
BinsertOne()
CinsertMany()
DinsertArray()
What type of argument does insertMany() expect?
AAn array of document objects
BA single document object
CA string
DA number
If one document fails during insertMany(), what happens by default?
AAll documents are inserted anyway
BThe operation stops and returns an error
COnly the failed document is skipped
DThe database crashes
Which option allows insertMany() to continue inserting after an error?
Aordered:false
Bordered:true
Ccontinue:true
DskipErrors:true
Can you insert an empty array with insertMany()?
AYes, it inserts an empty document
BYes, it inserts a null document
COnly if you set a special flag
DNo, it does nothing
Explain how to insert multiple documents in MongoDB using arrays.
Think about the method name and what it expects as input.
You got /4 concepts.
    Describe what happens if one document in an insertMany array fails to insert.
    Consider the default behavior and how to change it.
    You got /3 concepts.