0
0
MongoDBquery~10 mins

MongoDB Shell (mongosh) basics - Interactive Code Practice

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

Complete the code to show all databases in MongoDB shell.

MongoDB
show [1]
Drag options to blanks, or click blank then click option'
Adatabases
Bdocs
Ctables
Dcollections
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'show collections' instead of 'show databases'.
Typing 'show tables' which is not a MongoDB command.
2fill in blank
medium

Complete the code to switch to a database named 'school'.

MongoDB
use [1]
Drag options to blanks, or click blank then click option'
Aschool
Bstudents
Cadmin
Dtest
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'use students' instead of 'use school'.
Typing 'use admin' which switches to the admin database.
3fill in blank
hard

Fix the error in the command to list collections in the current database.

MongoDB
db.[1]()
Drag options to blanks, or click blank then click option'
AshowCollections
Bcollections
ClistCollections
Dshow
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'db.showCollections()' which is not a valid method.
Using 'db.collections()' which does not exist.
4fill in blank
hard

Fill both blanks to insert a document with name 'Alice' and age 25 into the 'users' collection.

MongoDB
db.users.[1]([2])
Drag options to blanks, or click blank then click option'
AinsertOne
B{ name: 'Alice', age: 25 }
C{ name: 'Bob', age: 30 }
DinsertMany
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'insertMany' when inserting only one document.
Inserting the wrong document data.
5fill in blank
hard

Fill all three blanks to find all documents in 'products' collection where price is greater than 100.

MongoDB
db.products.[1]([2]: { [3]: 100 })
Drag options to blanks, or click blank then click option'
Afind
Bprice
C$gt
DinsertOne
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'insertOne' instead of 'find'.
Using wrong operator like '$lt' instead of '$gt'.