0
0
MongoDBquery~10 mins

find method basics in MongoDB - Interactive Code Practice

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'
Ainsert
Bupdate
Cfind
Ddelete
Attempts:
3 left
💡 Hint
Common Mistakes
Using insert() instead of find().
Using update() or delete() which modify data.
2fill in blank
medium

Complete the code to find documents where the field 'age' is 25.

MongoDB
db.collection.find([1]: 25})
Drag options to blanks, or click blank then click option'
Astatus
Bage
Cscore
Dname
Attempts:
3 left
💡 Hint
Common Mistakes
Using the wrong field name in the query.
Not using an object inside find().
3fill in blank
hard

Fix the error in the code to find documents with 'status' equal to 'active'.

MongoDB
db.collection.find({status: [1])
Drag options to blanks, or click blank then click option'
A'active'
Bactive"
Cactive
D"active"
Attempts:
3 left
💡 Hint
Common Mistakes
Not quoting string values.
Using mismatched or missing quotes.
4fill in blank
hard

Fill both blanks to find documents where 'score' is greater than 80.

MongoDB
db.collection.find({score: { [1]: [2] }})
Drag options to blanks, or click blank then click option'
A$gt
B$lt
C80
D100
Attempts:
3 left
💡 Hint
Common Mistakes
Using $lt which means 'less than'.
Using wrong comparison values.
5fill in blank
hard

Fill all three blanks to find documents where 'age' is less than 30 and only show the 'name' field.

MongoDB
db.collection.find([1]: { [2]: [3] }}, {name: 1})
Drag options to blanks, or click blank then click option'
Aage
B$lt
C30
D$gt
Attempts:
3 left
💡 Hint
Common Mistakes
Using wrong operators like $gt.
Not specifying the projection correctly.