Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to find all documents in the collection.
MongoDB
db.collection.[1]() Drag options to blanks, or click blank then click option'
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.
✗ Incorrect
The find() method retrieves all documents from a MongoDB collection.
2fill in blank
mediumComplete 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'
Attempts:
3 left
💡 Hint
Common Mistakes
Using find will not add data.
Using deleteOne or updateOne will remove or change data, not add.
✗ Incorrect
The insertOne() method adds a single new document to the collection.
3fill in blank
hardFix 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'
Attempts:
3 left
💡 Hint
Common Mistakes
Missing the dollar sign causes the update to fail.
Using 'set' without $ is not recognized by MongoDB.
✗ Incorrect
The $set operator updates specific fields in a document.
4fill in blank
hardFill 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'
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.
✗ Incorrect
The $gt operator means 'greater than'. So this finds documents with age > 25.
5fill in blank
hardFill 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'
Attempts:
3 left
💡 Hint
Common Mistakes
Using wrong name string changes the filter.
Using $gt instead of $lt reverses the age condition.
✗ Incorrect
This query finds documents where name is 'Eve' and age is less than 40 using $lt.