0
0
MongoDBquery~10 mins

Why modeling decisions matter in MongoDB - Test Your Understanding

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

Complete the code to find all documents in the collection.

MongoDB
db.collection.[1]()
Drag options to blanks, or click blank then click option'
Afind
Binsert
Cupdate
Ddelete
Attempts:
3 left
💡 Hint
Common Mistakes
Using insert instead of find will add data, not retrieve it.
Using update or delete will modify or remove data, not retrieve.
2fill in blank
medium

Complete the code to insert a new document into the collection.

MongoDB
db.collection.[1]({ name: 'Alice', age: 30 })
Drag options to blanks, or click blank then click option'
AdeleteOne
Bfind
CinsertOne
DupdateOne
Attempts:
3 left
💡 Hint
Common Mistakes
Using find will not add data.
Using deleteOne or updateOne will remove or change data, not add.
3fill in blank
hard

Fix the error in the query to update a document's age.

MongoDB
db.collection.updateOne({ name: 'Bob' }, { [1]: { age: 35 } })
Drag options to blanks, or click blank then click option'
Aupdate
Bset
C$update
D$set
Attempts:
3 left
💡 Hint
Common Mistakes
Missing the dollar sign causes the update to fail.
Using 'set' without $ is not recognized by MongoDB.
4fill in blank
hard

Fill both blanks to create a query that finds documents where age is greater than 25.

MongoDB
db.collection.find({ age: { [1]: [2] } })
Drag options to blanks, or click blank then click option'
A$gt
B25
C$lt
D30
Attempts:
3 left
💡 Hint
Common Mistakes
Using $lt finds ages less than the number, not greater.
Using 30 instead of 25 changes the filter condition.
5fill in blank
hard

Fill all three blanks to create a query that finds documents with name 'Eve' and age less than 40.

MongoDB
db.collection.find({ name: [1], age: { [2]: [3] } })
Drag options to blanks, or click blank then click option'
A'Eve'
B$lt
C40
D'Alice'
Attempts:
3 left
💡 Hint
Common Mistakes
Using wrong name string changes the filter.
Using $gt instead of $lt reverses the age condition.