0
0
MongoDBquery~10 mins

Rows vs documents thinking 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 find all documents in the collection.

MongoDB
db.collection.[1]()
Drag options to blanks, or click blank then click option'
Aget
Bfind
Cselect
Dquery
Attempts:
3 left
💡 Hint
Common Mistakes
Using SQL terms like 'select' which is not a MongoDB method.
Trying to use 'get' or 'query' which are not valid MongoDB collection methods.
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'
AinsertOne
Bpush
Ccreate
Dadd
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'add' or 'push' which are not MongoDB methods.
Confusing with SQL INSERT syntax.
3fill in blank
hard

Fix the error in the query to find documents where age is greater than 25.

MongoDB
db.collection.find({ age: { [1]: 25 } })
Drag options to blanks, or click blank then click option'
A$ne
B$lt
C$gt
D$eq
Attempts:
3 left
💡 Hint
Common Mistakes
Using '$lt' which means less than.
Using '$eq' which means equals.
4fill in blank
hard

Fill both blanks to update the age of a document where name is 'Bob'.

MongoDB
db.collection.updateOne({ name: 'Bob' }, { [1]: { age: [2] } })
Drag options to blanks, or click blank then click option'
A$set
B$inc
C35
D40
Attempts:
3 left
💡 Hint
Common Mistakes
Using '$inc' which increments instead of setting a value.
Choosing a wrong number for age.
5fill in blank
hard

Fill all three blanks to create a document with nested address information.

MongoDB
db.collection.insertOne({ name: 'Eve', address: { [1]: '123 Main St', [2]: 'Springfield', [3]: 'IL' } })
Drag options to blanks, or click blank then click option'
Astreet
Bcity
Cstate
Dzip
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'zip' instead of 'state' for the last field.
Mixing up the order of city and state.