0
0
MongoDBquery~10 mins

Why the paradigm shift matters 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() to get data.
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'
AupdateOne
BinsertOne
CdeleteOne
Dfind
Attempts:
3 left
💡 Hint
Common Mistakes
Using find() to add data instead of insertOne().
3fill in blank
hard

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

MongoDB
db.collection.updateOne({ name: 'Alice' }, { [1]: { age: 31 } })
Drag options to blanks, or click blank then click option'
A$set
B$get
C$add
D$remove
Attempts:
3 left
💡 Hint
Common Mistakes
Using $get or $add which are not valid update operators.
4fill in blank
hard

Fill both blanks to find 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
B$lt
C25
D30
Attempts:
3 left
💡 Hint
Common Mistakes
Using $lt (less than) instead of $gt (greater than).
5fill in blank
hard

Fill all three blanks to delete documents where status is 'inactive' and age is less than 20.

MongoDB
db.collection.deleteMany({ status: [1], age: { [2]: [3] } })
Drag options to blanks, or click blank then click option'
A'inactive'
B$lt
C20
D'active'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'active' instead of 'inactive' for status.