0
0
MongoDBquery~10 mins

Ordered vs unordered inserts in MongoDB - Interactive Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to perform an ordered insert of multiple documents in MongoDB.

MongoDB
db.collection.insertMany([{name: 'Alice'}, {name: 'Bob'}], {ordered: [1])
Drag options to blanks, or click blank then click option'
Afalse
Btrue
Cnull
Dundefined
Attempts:
3 left
💡 Hint
Common Mistakes
Using false will make inserts unordered, which is not what is asked.
2fill in blank
medium

Complete the code to perform an unordered insert of multiple documents in MongoDB.

MongoDB
db.collection.insertMany([{name: 'Carol'}, {name: 'Dave'}], {ordered: [1])
Drag options to blanks, or click blank then click option'
Atrue
Bundefined
Cnull
Dfalse
Attempts:
3 left
💡 Hint
Common Mistakes
Using true will stop inserts on the first error.
3fill in blank
hard

Fix the error in the code to correctly perform an unordered insert.

MongoDB
db.collection.insertMany([{name: 'Eve'}, {name: 'Frank'}], {ordered: [1])
Drag options to blanks, or click blank then click option'
Afalse
Btrue
C0
D1
Attempts:
3 left
💡 Hint
Common Mistakes
Using 0 or 1 instead of boolean values causes errors.
4fill in blank
hard

Fill both blanks to perform an unordered insert and handle errors without stopping.

MongoDB
db.collection.insertMany([{name: 'Grace'}, {name: 'Heidi'}], {ordered: [1], [2]: true})
Drag options to blanks, or click blank then click option'
Afalse
BwriteConcern
CbypassDocumentValidation
Dtrue
Attempts:
3 left
💡 Hint
Common Mistakes
Using true for ordered inserts when unordered is needed.
5fill in blank
hard

Fill all three blanks to perform an unordered insert with write concern and bypass validation.

MongoDB
db.collection.insertMany([{name: 'Ivan'}, {name: 'Judy'}], {ordered: [1], [2]: 1, [3]: true})
Drag options to blanks, or click blank then click option'
Atrue
BwriteConcern
CbypassDocumentValidation
Dfalse
Attempts:
3 left
💡 Hint
Common Mistakes
Confusing ordered true/false and missing writeConcern option.